From 5cffbe66ddc2399d084e90ca79199b195165f24b Mon Sep 17 00:00:00 2001 From: chschrae Date: Tue, 10 Sep 2024 10:35:21 -0700 Subject: [PATCH 01/44] adding gitattributes to handle line endings --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..dada1ce9c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.cs text=auto +*.tsp text=auto \ No newline at end of file From 2fef8e9852f42510bbb1ad05da5a1016b44c7080 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Mon, 6 Jan 2025 15:24:02 -0800 Subject: [PATCH 02/44] resquish after tooling re-merge --- .dotnet/CHANGELOG.md | 13 + .dotnet/README.md | 68 + .dotnet/api/OpenAI.netstandard2.0.cs | 86 +- .../examples/Chat/Example09_ChatWithAudio.cs | 65 + .../Chat/Example10_ChatWithAudioAsync.cs | 66 + .../AssistantChatMessage.Serialization.cs | 123 +- .../src/Custom/Chat/AssistantChatMessage.cs | 6 + .dotnet/src/Custom/Chat/ChatAudioOptions.cs | 28 + .dotnet/src/Custom/Chat/ChatCompletion.cs | 19 +- .../src/Custom/Chat/ChatCompletionOptions.cs | 20 + .../src/Custom/Chat/ChatInputAudioFormat.cs | 11 + .dotnet/src/Custom/Chat/ChatMessage.cs | 19 +- .../ChatMessageContentPart.Serialization.cs | 21 +- .../src/Custom/Chat/ChatMessageContentPart.cs | 143 +- ...hatMessageContentPartKind.Serialization.cs | 2 + .../Custom/Chat/ChatMessageContentPartKind.cs | 4 +- .../src/Custom/Chat/ChatOutputAudioFormat.cs | 11 + .dotnet/src/Custom/Chat/ChatResponseVoice.cs | 11 + .../Custom/Chat/Internal/GeneratorStubs.cs | 18 +- ...ompletionRequestMessageContentPartAudio.cs | 11 + ...equestMessageContentPartAudioInputAudio.cs | 10 + .../src/Custom/Chat/OpenAIChatModelFactory.cs | 26 +- .../StreamingChatCompletionUpdate.cs | 23 +- .../RealtimeConversation/ConversationItem.cs | 2 +- .../Internal/GeneratorStubs.cs | 6 +- ...altimeClientEventResponseCreateResponse.cs | 17 +- .../Internal/InternalRealtimeResponseItem.cs | 4 +- .../InternalRealtimeResponseMessageItem.cs | 8 + .../RealtimeConversationSession.cs | 12 +- .../ConversationItemCreatedUpdate.cs | 2 +- ...ConversationItemStreamingFinishedUpdate.cs | 2 +- .../ConversationItemStreamingStartedUpdate.cs | 2 +- .../AssistantChatMessage.Serialization.cs | 99 +- .../Generated/Models/AssistantChatMessage.cs | 3 +- .../Models/ChatAudioOptions.Serialization.cs | 156 ++ .../src/Generated/Models/ChatAudioOptions.cs | 33 + .../ChatCompletionOptions.Serialization.cs | 57 + .../Generated/Models/ChatCompletionOptions.cs | 4 +- .../Generated/Models/ChatInputAudioFormat.cs | 44 + .../Models/ChatMessage.Serialization.cs | 10 +- .dotnet/src/Generated/Models/ChatMessage.cs | 4 +- .../Generated/Models/ChatOutputAudioFormat.cs | 53 + .../src/Generated/Models/ChatResponseVoice.cs | 56 + ...ersationItemCreatedUpdate.Serialization.cs | 6 +- .../Models/ConversationItemCreatedUpdate.cs | 4 +- ...emStreamingFinishedUpdate.Serialization.cs | 6 +- ...ConversationItemStreamingFinishedUpdate.cs | 4 +- ...temStreamingStartedUpdate.Serialization.cs | 6 +- .../ConversationItemStreamingStartedUpdate.cs | 4 +- .../FunctionChatMessage.Serialization.cs | 12 +- .../Generated/Models/FunctionChatMessage.cs | 2 +- ...mpletionMessageAudioChunk.Serialization.cs | 182 +++ ...InternalChatCompletionMessageAudioChunk.cs | 41 + ...uestAssistantMessageAudio.Serialization.cs | 145 ++ ...tCompletionRequestAssistantMessageAudio.cs | 36 + ...stMessageContentPartAudio.Serialization.cs | 156 ++ ...ompletionRequestMessageContentPartAudio.cs | 39 + ...ontentPartAudioInputAudio.Serialization.cs | 156 ++ ...equestMessageContentPartAudioInputAudio.cs | 40 + ...etionRequestMessageContentPartAudioType.cs | 41 + ...CompletionResponseMessage.Serialization.cs | 24 + .../InternalChatCompletionResponseMessage.cs | 5 +- ...etionResponseMessageAudio.Serialization.cs | 178 +++ ...ernalChatCompletionResponseMessageAudio.cs | 45 + ...letionStreamResponseDelta.Serialization.cs | 16 + ...ternalChatCompletionStreamResponseDelta.cs | 5 +- ...rnalCreateChatCompletionRequestModality.cs | 44 + ...nternalCreateChatCompletionRequestModel.cs | 6 + ...onRequestAssistantMessage.Serialization.cs | 26 +- ...neChatCompletionRequestAssistantMessage.cs | 2 +- ...ClientEventResponseCreate.Serialization.cs | 4 +- ...ternalRealtimeClientEventResponseCreate.cs | 6 +- ...ConversationResponseItem.Serialization.cs} | 50 +- ...ternalRealtimeConversationResponseItem.cs} | 8 +- ...lRealtimeConversationResponseItemObject.cs | 41 + ...eResponseFunctionCallItem.Serialization.cs | 8 +- ...nternalRealtimeResponseFunctionCallItem.cs | 4 +- ...nseFunctionCallOutputItem.Serialization.cs | 8 +- ...lRealtimeResponseFunctionCallOutputItem.cs | 4 +- .../InternalRealtimeResponseItemObject.cs | 41 - ...altimeResponseMessageItem.Serialization.cs | 54 +- .../InternalRealtimeResponseMessageItem.cs | 10 +- ...lRealtimeResponseOptions.Serialization.cs} | 94 +- ....cs => InternalRealtimeResponseOptions.cs} | 14 +- ...nternalUnknownChatMessage.Serialization.cs | 12 +- .../Models/InternalUnknownChatMessage.cs | 2 +- ...amingChatCompletionUpdate.Serialization.cs | 12 +- .../Models/SystemChatMessage.Serialization.cs | 12 +- .../src/Generated/Models/SystemChatMessage.cs | 2 +- .../Models/ToolChatMessage.Serialization.cs | 12 +- .../src/Generated/Models/ToolChatMessage.cs | 2 +- ...knownRealtimeResponseItem.Serialization.cs | 40 +- .../Models/UnknownRealtimeResponseItem.cs | 4 +- .../Models/UserChatMessage.Serialization.cs | 12 +- .../src/Generated/Models/UserChatMessage.cs | 2 +- .dotnet/src/Generated/OpenAIModelFactory.cs | 49 +- .dotnet/tests/Chat/ChatSmokeTests.cs | 98 ++ .dotnet/tests/Chat/ChatTests.cs | 67 +- .dotnet/tests/Utility/TestHelpers.cs | 63 +- .dotnet/tests/Utility/TestPipelinePolicy.cs | 16 +- .openapi3/openapi3-openai.yaml | 504 ++++--- .scripts/Edit-Serialization.ps1 | 69 +- .scripts/Update-ClientModel.ps1 | 2 +- .typespec/chat/custom.tsp | 11 + .typespec/chat/models.tsp | 111 +- .typespec/realtime/custom.tsp | 72 +- .typespec/realtime/custom/items.tsp | 23 +- .typespec/realtime/models.tsp | 277 ++-- README.md | 7 +- openapi3-original.yaml | 1305 +++++++++-------- 110 files changed, 4293 insertions(+), 1448 deletions(-) create mode 100644 .dotnet/examples/Chat/Example09_ChatWithAudio.cs create mode 100644 .dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs create mode 100644 .dotnet/src/Custom/Chat/ChatAudioOptions.cs create mode 100644 .dotnet/src/Custom/Chat/ChatInputAudioFormat.cs create mode 100644 .dotnet/src/Custom/Chat/ChatOutputAudioFormat.cs create mode 100644 .dotnet/src/Custom/Chat/ChatResponseVoice.cs create mode 100644 .dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudio.cs create mode 100644 .dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs create mode 100644 .dotnet/src/Generated/Models/ChatAudioOptions.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/ChatAudioOptions.cs create mode 100644 .dotnet/src/Generated/Models/ChatInputAudioFormat.cs create mode 100644 .dotnet/src/Generated/Models/ChatOutputAudioFormat.cs create mode 100644 .dotnet/src/Generated/Models/ChatResponseVoice.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudio.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudio.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioInputAudio.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioType.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.cs create mode 100644 .dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModality.cs rename .dotnet/src/Generated/Models/{InternalRealtimeResponseItem.Serialization.cs => InternalRealtimeConversationResponseItem.Serialization.cs} (61%) rename .dotnet/src/Generated/Models/{InternalRealtimeResponseItem.cs => InternalRealtimeConversationResponseItem.cs} (60%) create mode 100644 .dotnet/src/Generated/Models/InternalRealtimeConversationResponseItemObject.cs delete mode 100644 .dotnet/src/Generated/Models/InternalRealtimeResponseItemObject.cs rename .dotnet/src/Generated/Models/{InternalRealtimeClientEventResponseCreateResponse.Serialization.cs => InternalRealtimeResponseOptions.Serialization.cs} (68%) rename .dotnet/src/Generated/Models/{InternalRealtimeClientEventResponseCreateResponse.cs => InternalRealtimeResponseOptions.cs} (60%) diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index 8a8d68fa1..47879fd8b 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -1,5 +1,18 @@ # Release History +## 2.2.0-beta.1 (Unreleased) + +### Features added + +- Chat completion now supports audio input and output! + - To configure a chat completion to request audio output using the `gpt-4o-audio-preview` model, create a `ChatAudioOptions` instance and provide it on `ChatCompletionOptions.AudioOptions`. + - Audio is always represented as a `ChatMessageContentPart`: + - User audio input can be instantiated via `ChatMessageContentPart.CreateAudioPart(BinaryData, ChatAudioInputFormat)` and will populate the `AudioBytes` and `AudioInputFormat` properties on `ChatMessageContentPart` + - Response audio associated with the items in `Content` of a `ChatCompletion` or `ContentUpdate` of a `StreamingChatCompletionUpdate` will populate the `AudioBytes`, `AudioTranscript`, `AudioExpiresAt`, and `AudioCorrelationId` properties + - Audio referring to a previous response's output can be created via `ChatMessageContentPart.CreateAudioPart(string)` and will populate the `AudioCorrelationId` property. + - The `AssistantChatMessage(IEnumerable)` and `AssistantChatMessage(ChatCompletion)` constructors will automatically infer `AudioCorrelationId`, simplifying conversation history management + - For more information, see the example in the README + ## 2.1.0 (2024-12-04) ### Features added diff --git a/.dotnet/README.md b/.dotnet/README.md index 2d138e8a6..d0d710937 100644 --- a/.dotnet/README.md +++ b/.dotnet/README.md @@ -18,6 +18,7 @@ It is generated from our [OpenAPI specification](https://github.com/openai/opena - [How to use chat completions with streaming](#how-to-use-chat-completions-with-streaming) - [How to use chat completions with tools and function calling](#how-to-use-chat-completions-with-tools-and-function-calling) - [How to use chat completions with structured outputs](#how-to-use-chat-completions-with-structured-outputs) +- [How to use chat completions with audio](#how-to-use-chat-completions-with-audio) - [How to generate text embeddings](#how-to-generate-text-embeddings) - [How to generate images](#how-to-generate-images) - [How to transcribe audio](#how-to-transcribe-audio) @@ -354,6 +355,73 @@ foreach (JsonElement stepElement in structuredJson.RootElement.GetProperty("step } ``` +## How to use chat completions with audio + +Starting with the `gpt-4o-audio-preview` model, chat completions can process audio input and output. + +This example demonstrates: + 1. Configuring the client with the supported `gpt-4o-audio-preview` model + 1. Supplying user audio input on a chat completion request + 1. Requesting model audio output from the chat completion operation + 1. Retrieving audio output from a `ChatCompletion` instance + 1. Using past audio output as `ChatMessage` conversation history + +```csharp +// Chat audio input and output is only supported on specific models, beginning with gpt-4o-audio-preview +ChatClient client = new("gpt-4o-audio-preview", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); + +// Input audio is provided to a request by adding an audio content part to a user message +string audioFilePath = Path.Combine("Assets", "whats_the_weather_pcm16_24khz_mono.wav"); +byte[] audioFileRawBytes = File.ReadAllBytes(audioFilePath); +BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); +List messages = + [ + new UserChatMessage(ChatMessageContentPart.CreateAudioPart(audioData, ChatInputAudioFormat.Wav)), + ]; + +// Output audio is requested by configuring AudioOptions on ChatCompletionOptions +ChatCompletionOptions options = new() +{ + AudioOptions = new(ChatResponseVoice.Alloy, ChatOutputAudioFormat.Mp3), +}; + +ChatCompletion completion = client.CompleteChat(messages, options); + +void PrintAudioContent() +{ + foreach (ChatMessageContentPart contentPart in completion.Content) + { + if (contentPart.AudioCorrelationId is not null) + { + Console.WriteLine($"Response audio transcript: {contentPart.AudioTranscript}"); + + string outputFilePath = $"{contentPart.AudioCorrelationId}.mp3"; + using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) + { + outputFileStream.Write(contentPart.AudioBytes); + } + Console.WriteLine($"Response audio written to file: {outputFilePath}"); + Console.WriteLine($"Valid on followup requests until: {contentPart.AudioExpiresAt}"); + } + } +} + +PrintAudioContent(); + +// To refer to past audio output, create an assistant message from the earlier ChatCompletion, use the earlier +// response content part, or use ChatMessageContentPart.CreateAudioPart(string) to manually instantiate a part. + +messages.Add(new AssistantChatMessage(completion)); +messages.Add("Can you say that like a pirate?"); + +completion = client.CompleteChat(messages, options); + +PrintAudioContent(); +``` + +Streaming is virtually identical: items in `StreamingChatCompletionUpdate.ContentUpdate` will provide incremental chunks of data via +`AudioBytes` and `AudioTranscript`. + ## How to generate text embeddings In this example, you want to create a trip-planning website that allows customers to write a prompt describing the kind of hotel that they are looking for and then offers hotel recommendations that closely match this description. To achieve this, it is possible to use text embeddings to measure the relatedness of text strings. In summary, you can get embeddings of the hotel descriptions, store them in a vector database, and use them to build a search index that you can query using the embedding of a given customer's prompt. diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 795808816..9825a6582 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1627,6 +1627,22 @@ public class AssistantChatMessage : ChatMessage, IJsonModel.GetFormatFromOptions(ModelReaderWriterOptions options); BinaryData IPersistableModel.Write(ModelReaderWriterOptions options); } + public class ChatAudioOptions : IJsonModel, IPersistableModel { + public ChatAudioOptions(ChatResponseVoice responseVoice, ChatOutputAudioFormat outputAudioFormat); + public ChatOutputAudioFormat OutputAudioFormat { get; set; } + public ChatResponseVoice ResponseVoice { get; set; } + protected virtual ChatAudioOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options); + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options); + public static explicit operator ChatAudioOptions(ClientResult result); + public static implicit operator BinaryContent(ChatAudioOptions chatAudioOptions); + protected virtual ChatAudioOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options); + ChatAudioOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options); + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options); + ChatAudioOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options); + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options); + } public class ChatClient { protected ChatClient(); protected internal ChatClient(ClientPipeline pipeline, string model, OpenAIClientOptions options); @@ -1676,6 +1692,7 @@ public class ChatCompletion : IJsonModel, IPersistableModel, IPersistableModel { public bool? AllowParallelToolCalls { get; set; } + public ChatAudioOptions AudioOptions { get; set; } public string EndUserId { get; set; } public float? FrequencyPenalty { get; set; } [Obsolete("This property is obsolete. Please use ToolChoice instead.")] @@ -1784,6 +1801,22 @@ public class ChatFunctionChoice : IJsonModel, IPersistableMo public static bool operator !=(ChatImageDetailLevel left, ChatImageDetailLevel right); public override readonly string ToString(); } + public readonly partial struct ChatInputAudioFormat : IEquatable { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ChatInputAudioFormat(string value); + public static ChatInputAudioFormat Mp3 { get; } + public static ChatInputAudioFormat Wav { get; } + public readonly bool Equals(ChatInputAudioFormat other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(ChatInputAudioFormat left, ChatInputAudioFormat right); + public static implicit operator ChatInputAudioFormat(string value); + public static bool operator !=(ChatInputAudioFormat left, ChatInputAudioFormat right); + public override readonly string ToString(); + } public class ChatInputTokenUsageDetails : IJsonModel, IPersistableModel { public int AudioTokenCount { get; } public int CachedTokenCount { get; } @@ -1838,6 +1871,11 @@ public class ChatMessageContent : ObjectModel.Collection public ChatMessageContent(string content); } public class ChatMessageContentPart : IJsonModel, IPersistableModel { + public BinaryData AudioBytes { get; } + public string AudioCorrelationId { get; } + public DateTimeOffset? AudioExpiresAt { get; } + public ChatInputAudioFormat? AudioInputFormat { get; } + public string AudioTranscript { get; } public BinaryData ImageBytes { get; } public string ImageBytesMediaType { get; } public ChatImageDetailLevel? ImageDetailLevel { get; } @@ -1845,6 +1883,8 @@ public class ChatMessageContentPart : IJsonModel, IPersi public ChatMessageContentPartKind Kind { get; } public string Refusal { get; } public string Text { get; } + public static ChatMessageContentPart CreateAudioPart(BinaryData audioBytes, ChatInputAudioFormat audioFormat); + public static ChatMessageContentPart CreateAudioPart(string audioCorrelationId); public static ChatMessageContentPart CreateImagePart(BinaryData imageBytes, string imageBytesMediaType, ChatImageDetailLevel? imageDetailLevel = null); public static ChatMessageContentPart CreateImagePart(Uri imageUri, ChatImageDetailLevel? imageDetailLevel = null); public static ChatMessageContentPart CreateRefusalPart(string refusal); @@ -1865,7 +1905,8 @@ public class ChatMessageContentPart : IJsonModel, IPersi public enum ChatMessageContentPartKind { Text = 0, Refusal = 1, - Image = 2 + Image = 2, + Audio = 3 } public enum ChatMessageRole { System = 0, @@ -1874,6 +1915,25 @@ public enum ChatMessageRole { Tool = 3, Function = 4 } + public readonly partial struct ChatOutputAudioFormat : IEquatable { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ChatOutputAudioFormat(string value); + public static ChatOutputAudioFormat Flac { get; } + public static ChatOutputAudioFormat Mp3 { get; } + public static ChatOutputAudioFormat Opus { get; } + public static ChatOutputAudioFormat Pcm16 { get; } + public static ChatOutputAudioFormat Wav { get; } + public readonly bool Equals(ChatOutputAudioFormat other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(ChatOutputAudioFormat left, ChatOutputAudioFormat right); + public static implicit operator ChatOutputAudioFormat(string value); + public static bool operator !=(ChatOutputAudioFormat left, ChatOutputAudioFormat right); + public override readonly string ToString(); + } public class ChatOutputTokenUsageDetails : IJsonModel, IPersistableModel { public int AudioTokenCount { get; } public int ReasoningTokenCount { get; } @@ -1905,6 +1965,26 @@ public class ChatResponseFormat : IJsonModel, IPersistableMo string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options); BinaryData IPersistableModel.Write(ModelReaderWriterOptions options); } + public readonly partial struct ChatResponseVoice : IEquatable { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ChatResponseVoice(string value); + public static ChatResponseVoice Alloy { get; } + public static ChatResponseVoice Echo { get; } + public static ChatResponseVoice Fable { get; } + public static ChatResponseVoice Nova { get; } + public static ChatResponseVoice Onyx { get; } + public static ChatResponseVoice Shimmer { get; } + public readonly bool Equals(ChatResponseVoice other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(ChatResponseVoice left, ChatResponseVoice right); + public static implicit operator ChatResponseVoice(string value); + public static bool operator !=(ChatResponseVoice left, ChatResponseVoice right); + public override readonly string ToString(); + } public class ChatTokenLogProbabilityDetails : IJsonModel, IPersistableModel { public float LogProbability { get; } public string Token { get; } @@ -2033,13 +2113,13 @@ public class FunctionChatMessage : ChatMessage, IJsonModel, BinaryData IPersistableModel.Write(ModelReaderWriterOptions options); } public static class OpenAIChatModelFactory { - public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null); + public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, BinaryData audioBytes = null, string audioCorrelationId = null, string audioTranscript = null, DateTimeOffset? audioExpiresAt = null); public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = 0, int cachedTokenCount = 0); public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = 0, int audioTokenCount = 0); public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null); public static ChatTokenTopLogProbabilityDetails ChatTokenTopLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null); public static ChatTokenUsage ChatTokenUsage(int outputTokenCount = 0, int inputTokenCount = 0, int totalTokenCount = 0, ChatOutputTokenUsageDetails outputTokenDetails = null, ChatInputTokenUsageDetails inputTokenDetails = null); - public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string completionId = null, ChatMessageContent contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null); + public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string completionId = null, ChatMessageContent contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, string audioCorrelationId = null, string audioTranscript = null, BinaryData audioBytes = null, DateTimeOffset? audioExpiresAt = null); [Obsolete("This class is obsolete. Please use StreamingChatToolCallUpdate instead.")] public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionName = null, BinaryData functionArgumentsUpdate = null); public static StreamingChatToolCallUpdate StreamingChatToolCallUpdate(int index = 0, string toolCallId = null, ChatToolCallKind kind = ChatToolCallKind.Function, string functionName = null, BinaryData functionArgumentsUpdate = null); diff --git a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs new file mode 100644 index 000000000..758e538e2 --- /dev/null +++ b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs @@ -0,0 +1,65 @@ +using NUnit.Framework; +using OpenAI.Chat; +using System; +using System.Collections.Generic; +using System.IO; + +namespace OpenAI.Examples; + +public partial class ChatExamples +{ + [Test] + public void Example09_ChatWithAudio() + { + // Chat audio input and output is only supported on specific models, beginning with gpt-4o-audio-preview + ChatClient client = new("gpt-4o-audio-preview", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); + + // Input audio is provided to a request by adding an audio content part to a user message + string audioFilePath = Path.Combine("Assets", "whats_the_weather_pcm16_24khz_mono.wav"); + byte[] audioFileRawBytes = File.ReadAllBytes(audioFilePath); + BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); + List messages = + [ + new UserChatMessage(ChatMessageContentPart.CreateAudioPart(audioData, ChatInputAudioFormat.Wav)), + ]; + + // Output audio is requested by configuring AudioOptions on ChatCompletionOptions + ChatCompletionOptions options = new() + { + AudioOptions = new(ChatResponseVoice.Alloy, ChatOutputAudioFormat.Mp3), + }; + + ChatCompletion completion = client.CompleteChat(messages, options); + + void PrintAudioContent() + { + foreach (ChatMessageContentPart contentPart in completion.Content) + { + if (contentPart.AudioCorrelationId is not null) + { + Console.WriteLine($"Response audio transcript: {contentPart.AudioTranscript}"); + + string outputFilePath = $"{contentPart.AudioCorrelationId}.mp3"; + using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) + { + outputFileStream.Write(contentPart.AudioBytes); + } + Console.WriteLine($"Response audio written to file: {outputFilePath}"); + Console.WriteLine($"Valid on followup requests until: {contentPart.AudioExpiresAt}"); + } + } + } + + PrintAudioContent(); + + // To refer to past audio output, create an assistant message from the earlier ChatCompletion, use the earlier + // response content part, or use ChatMessageContentPart.CreateAudioPart(string) to manually instantiate a part. + + messages.Add(new AssistantChatMessage(completion)); + messages.Add("Can you say that like a pirate?"); + + completion = client.CompleteChat(messages, options); + + PrintAudioContent(); + } +} diff --git a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs new file mode 100644 index 000000000..1a8f70748 --- /dev/null +++ b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs @@ -0,0 +1,66 @@ +using NUnit.Framework; +using OpenAI.Chat; +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; + +namespace OpenAI.Examples; + +public partial class ChatExamples +{ + [Test] + public async Task Example09_ChatWithAudioAsync() + { + // Chat audio input and output is only supported on specific models, beginning with gpt-4o-audio-preview + ChatClient client = new("gpt-4o-audio-preview", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); + + // Input audio is provided to a request by adding an audio content part to a user message + string audioFilePath = Path.Combine("Assets", "whats_the_weather_pcm16_24khz_mono.wav"); + byte[] audioFileRawBytes = await File.ReadAllBytesAsync(audioFilePath); + BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); + List messages = + [ + new UserChatMessage(ChatMessageContentPart.CreateAudioPart(audioData, ChatInputAudioFormat.Wav)), + ]; + + // Output audio is requested by configuring AudioOptions on ChatCompletionOptions + ChatCompletionOptions options = new() + { + AudioOptions = new(ChatResponseVoice.Alloy, ChatOutputAudioFormat.Mp3), + }; + + ChatCompletion completion = await client.CompleteChatAsync(messages, options); + + async Task PrintAudioContentAsync() + { + foreach (ChatMessageContentPart contentPart in completion.Content) + { + if (contentPart.AudioCorrelationId is not null) + { + Console.WriteLine($"Response audio transcript: {contentPart.AudioTranscript}"); + + string outputFilePath = $"{contentPart.AudioCorrelationId}.mp3"; + using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) + { + await outputFileStream.WriteAsync(contentPart.AudioBytes); + } + Console.WriteLine($"Response audio written to file: {outputFilePath}"); + Console.WriteLine($"Valid on followup requests until: {contentPart.AudioExpiresAt}"); + } + } + } + + await PrintAudioContentAsync(); + + // To refer to past audio output, create an assistant message from the earlier ChatCompletion, use the earlier + // response content part, or use ChatMessageContentPart.CreateAudioPart(string) to manually instantiate a part. + + messages.Add(new AssistantChatMessage(completion)); + messages.Add("Can you say that like a pirate?"); + + completion = await client.CompleteChatAsync(messages, options); + + await PrintAudioContentAsync(); + } +} diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs index d5fac5775..13e493295 100644 --- a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs @@ -1,4 +1,7 @@ +using System; using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; using System.Text.Json; namespace OpenAI.Chat; @@ -19,9 +22,22 @@ internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions writer.WriteStringValue(Role.ToSerialString()); // Content is optional, can be a single string or a collection of ChatMessageContentPart. - if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) + if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined() && Content.Count > 0) { - if (Content.Count > 0) + // AssistantChatMessage contrives a ChatMessageContent instance to expose the otherwise unrelated audio + // information as multimodal content. For serialization, we need to ensure the underlying, non-projected + // representation is populated. + if (Audio is null) + { + ChatMessageContentPart audioReferenceContentPart + = Content.FirstOrDefault(contentPart => !string.IsNullOrEmpty(contentPart.AudioCorrelationId)); + if (audioReferenceContentPart is not null) + { + Audio = new(audioReferenceContentPart.AudioCorrelationId); + } + } + + if (Content.Any(contentPart => !contentPart.IsContrived)) { writer.WritePropertyName("content"u8); if (Content.Count == 1 && Content[0].Text != null) @@ -33,7 +49,10 @@ internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions writer.WriteStartArray(); foreach (ChatMessageContentPart part in Content) { - writer.WriteObjectValue(part, options); + if (!part.IsContrived) + { + writer.WriteObjectValue(part, options); + } } writer.WriteEndArray(); } @@ -44,7 +63,105 @@ internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions writer.WriteOptionalProperty("name"u8, ParticipantName, options); writer.WriteOptionalCollection("tool_calls"u8, ToolCalls, options); writer.WriteOptionalProperty("function_call"u8, FunctionCall, options); + writer.WriteOptionalProperty("audio"u8, Audio, options); writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); writer.WriteEndObject(); } + + internal static AssistantChatMessage DeserializeAssistantChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + string refusal = default; + string name = default; + InternalChatCompletionRequestAssistantMessageAudio audio = default; + IList toolCalls = default; + ChatFunctionCall functionCall = default; + ChatMessageRole role = default; + ChatMessageContent content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("refusal"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + refusal = null; + continue; + } + refusal = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("audio"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + audio = null; + continue; + } + audio = InternalChatCompletionRequestAssistantMessageAudio.DeserializeInternalChatCompletionRequestAssistantMessageAudio(property.Value, options); + 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().ToChatMessageRole(); + continue; + } + if (property.NameEquals("content"u8)) + { + DeserializeContentValue(property, ref content); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + // CUSTOM: Initialize Content collection property. + // If applicable, prepend a contrived content part representing an ID-based audio reference. + content ??= new(); + if (audio is not null) + { + content.Insert(0, new ChatMessageContentPart(ChatMessageContentPartKind.Audio, audioReference: new(audio.Id))); + } + return new AssistantChatMessage( + content ?? new ChatMessageContent(), + role, + serializedAdditionalRawData, + refusal, + name, + toolCalls ?? new ChangeTrackingList(), + functionCall, + audio); + } } diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.cs b/.dotnet/src/Custom/Chat/AssistantChatMessage.cs index db2b80de3..d1a03084c 100644 --- a/.dotnet/src/Custom/Chat/AssistantChatMessage.cs +++ b/.dotnet/src/Custom/Chat/AssistantChatMessage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; namespace OpenAI.Chat; @@ -113,6 +114,7 @@ public AssistantChatMessage(ChatCompletion chatCompletion) { ToolCalls.Add(toolCall); } + // Note: The internal Audio property will be populated via reprojected Content upon serialization. } // CUSTOM: Renamed. @@ -129,4 +131,8 @@ public AssistantChatMessage(ChatCompletion chatCompletion) [Obsolete($"This property is obsolete. Please use {nameof(ToolCalls)} instead.")] public ChatFunctionCall FunctionCall { get; set; } + + // CUSTOM: Made internal for reprojected representation within the content collection. + [CodeGenMember("Audio")] + internal InternalChatCompletionRequestAssistantMessageAudio Audio { get; set; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatAudioOptions.cs b/.dotnet/src/Custom/Chat/ChatAudioOptions.cs new file mode 100644 index 000000000..e06a1e3ed --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatAudioOptions.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Chat; + +/// +/// Represents the configuration details for output audio requested in a chat completion request. +/// +/// +/// When provided to a instance's property, +/// the request's specified content modalities will be automatically updated to reflect desired audio output. +/// +[CodeGenModel("CreateChatCompletionRequestAudio")] +public partial class ChatAudioOptions +{ + /// + /// Gets or sets the voice model that the response should use to synthesize audio. + /// + [CodeGenMember("Voice")] + public ChatResponseVoice ResponseVoice { get; set; } + + /// + /// Specifies the output format desired for synthesized audio. + /// + [CodeGenMember("Format")] + public ChatOutputAudioFormat OutputAudioFormat { get; set; } +} diff --git a/.dotnet/src/Custom/Chat/ChatCompletion.cs b/.dotnet/src/Custom/Chat/ChatCompletion.cs index 03f9ea3f0..594aa61fc 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletion.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletion.cs @@ -71,7 +71,8 @@ public partial class ChatCompletion // CUSTOM: Flattened choice message property. /// The contents of the message. - public ChatMessageContent Content => Choices[0].Message.Content; + public ChatMessageContent Content => _content ??= GetWrappedContent(); + private ChatMessageContent _content; // CUSTOM: Flattened choice message property. /// The tool calls generated by the model, such as function calls. @@ -84,4 +85,20 @@ public partial class ChatCompletion // CUSTOM: Flattened choice message property. [Obsolete($"This property is obsolete. Please use {nameof(ToolCalls)} instead.")] public ChatFunctionCall FunctionCall => Choices[0].Message.FunctionCall; + + private ChatMessageContent GetWrappedContent() + { + if (Choices[0].Message.Audio is not null) + { + return new ChatMessageContent( + [ + new ChatMessageContentPart(ChatMessageContentPartKind.Audio, outputAudio: Choices[0].Message.Audio), + ..Choices[0].Message.Content, + ]); + } + else + { + return Choices[0].Message.Content; + } + } } diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs index d5b3b4545..78788dda5 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs @@ -176,4 +176,24 @@ public ChatCompletionOptions() /// [CodeGenMember("Store")] public bool? StoredOutputEnabled { get; set; } + + // CUSTOM: Made internal for automatic enablement via audio options. + [CodeGenMember("Modalities")] + private IList _internalModalities = new ChangeTrackingList(); + + // CUSTOM: supplemented with custom setter to internally enable audio output via modalities. + [CodeGenMember("Audio")] + private ChatAudioOptions _audioOptions; + + public ChatAudioOptions AudioOptions + { + get => _audioOptions; + set + { + _audioOptions = value; + _internalModalities = value is null + ? new ChangeTrackingList() + : [InternalCreateChatCompletionRequestModality.Text, InternalCreateChatCompletionRequestModality.Audio]; + } + } } diff --git a/.dotnet/src/Custom/Chat/ChatInputAudioFormat.cs b/.dotnet/src/Custom/Chat/ChatInputAudioFormat.cs new file mode 100644 index 000000000..cd32981ed --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatInputAudioFormat.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Chat; + +[CodeGenModel("ChatCompletionRequestMessageContentPartAudioInputAudioFormat")] +public readonly partial struct ChatInputAudioFormat +{ + +} diff --git a/.dotnet/src/Custom/Chat/ChatMessage.cs b/.dotnet/src/Custom/Chat/ChatMessage.cs index 78dcab46a..1adfbb38b 100644 --- a/.dotnet/src/Custom/Chat/ChatMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatMessage.cs @@ -56,6 +56,11 @@ namespace OpenAI.Chat; [CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))] public partial class ChatMessage { + /// + /// The content associated with the message. The interpretation of this content will vary depending on the message type. + /// + public ChatMessageContent Content { get; } = new ChatMessageContent(); + // CUSTOM: Changed type from string to ChatMessageRole. [CodeGenMember("Role")] internal ChatMessageRole Role { get; set; } @@ -76,7 +81,14 @@ internal ChatMessage(ChatMessageRole role, IEnumerable c { foreach (ChatMessageContentPart contentPart in contentParts) { - Content.Add(contentPart); + if (contentPart.Kind == ChatMessageContentPartKind.Audio && role == ChatMessageRole.Assistant) + { + Content.Add(new ChatMessageContentPart(ChatMessageContentPartKind.Audio, audioReference: new(contentPart.AudioCorrelationId))); + } + else + { + Content.Add(contentPart); + } } } } @@ -89,11 +101,6 @@ internal ChatMessage(ChatMessageRole role, string content = null) : this(role) } } - /// - /// The content associated with the message. The interpretation of this content will vary depending on the message type. - /// - public ChatMessageContent Content { get; } = new ChatMessageContent(); - #region SystemChatMessage /// public static SystemChatMessage CreateSystemMessage(string content) => new(content); diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs index eb2277bf6..8afaf8151 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs @@ -14,6 +14,13 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader internal static void WriteCoreContentPart(ChatMessageContentPart instance, Utf8JsonWriter writer, ModelReaderWriterOptions options) { + if (instance.IsContrived) + { + throw new InvalidOperationException( + $"Synthetic {nameof(ChatMessageContentPart)} instances cannot be directly serialized. " + + $"Instead, please serialize the owner of the {nameof(ChatMessageContent)} collection."); + } + writer.WriteStartObject(); writer.WritePropertyName("type"u8); writer.WriteStringValue(instance._kind.ToSerialString()); @@ -33,6 +40,11 @@ internal static void WriteCoreContentPart(ChatMessageContentPart instance, Utf8J writer.WritePropertyName("image_url"u8); writer.WriteObjectValue(instance._imageUri, options); } + else if (instance._kind == ChatMessageContentPartKind.Audio) + { + writer.WritePropertyName("input_audio"u8); + writer.WriteObjectValue(instance._inputAudio, options); + } writer.WriteSerializedAdditionalRawData(instance._additionalBinaryDataProperties, options); writer.WriteEndObject(); } @@ -50,6 +62,7 @@ internal static ChatMessageContentPart DeserializeChatMessageContentPart(JsonEle string text = default; string refusal = default; InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default; + InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -74,12 +87,18 @@ internal static ChatMessageContentPart DeserializeChatMessageContentPart(JsonEle refusal = property.Value.GetString(); continue; } + if (property.NameEquals("input_audio"u8)) + { + inputAudio = InternalChatCompletionRequestMessageContentPartAudioInputAudio + .DeserializeInternalChatCompletionRequestMessageContentPartAudioInputAudio(property.Value, options); + continue; + } if (true) { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new ChatMessageContentPart(kind, text, imageUri, refusal, serializedAdditionalRawData); + return new ChatMessageContentPart(kind, text, imageUri, refusal, inputAudio, outputAudio: null, responseAudioUpdate: null, audioReference: null, serializedAdditionalRawData); } } diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs index f170d8b83..65bce4bd7 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs @@ -28,6 +28,10 @@ public partial class ChatMessageContentPart private readonly ChatMessageContentPartKind _kind; private readonly string _text; private readonly InternalChatCompletionRequestMessageContentPartImageImageUrl _imageUri; + private readonly InternalChatCompletionRequestMessageContentPartAudioInputAudio _inputAudio; + private readonly InternalChatCompletionResponseMessageAudio _outputAudio; + private readonly InternalChatCompletionMessageAudioChunk _responseAudioUpdate; + private readonly InternalChatCompletionRequestAssistantMessageAudio _audioReference; private readonly string _refusal; // CUSTOM: Made internal. @@ -36,12 +40,25 @@ internal ChatMessageContentPart() } // CUSTOM: Added to support deserialization. - internal ChatMessageContentPart(ChatMessageContentPartKind kind, string text, InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri, string refusal, IDictionary serializedAdditionalRawData) + internal ChatMessageContentPart( + ChatMessageContentPartKind kind, + string text = default, + InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default, + string refusal = default, + InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default, + InternalChatCompletionResponseMessageAudio outputAudio = default, + InternalChatCompletionMessageAudioChunk responseAudioUpdate = default, + InternalChatCompletionRequestAssistantMessageAudio audioReference = default, + IDictionary serializedAdditionalRawData = default) { _kind = kind; _text = text; _imageUri = imageUri; _refusal = refusal; + _inputAudio = inputAudio; + _outputAudio = outputAudio; + _responseAudioUpdate = responseAudioUpdate; + _audioReference = audioReference; _additionalBinaryDataProperties = serializedAdditionalRawData; } @@ -68,6 +85,58 @@ internal ChatMessageContentPart(ChatMessageContentPartKind kind, string text, In /// Present when is . public string ImageBytesMediaType => _imageUri?.ImageBytesMediaType; + /// + /// The encoded binary audio payload associated with the content part. + /// + /// + /// Present when is and the content part + /// represents user role audio input or response audio content from the model. + /// + /// When streaming, this value represents the latest incremental audio update. + /// + /// + public BinaryData AudioBytes => _inputAudio?.Data ?? _outputAudio?.Data ?? _responseAudioUpdate?.Data; + + /// + /// The encoding format that the audio data provided in should be interpreted with. + /// + /// + /// Present when is and the content part + /// represents user role audio input. + /// + public ChatInputAudioFormat? AudioInputFormat => _inputAudio?.Format; + + /// + /// The unique identifier, as provided with model-generated response audio, that may be supplied as assistant + /// conversation history. + /// + /// + /// Present when is and the content part + /// represents response audio from the service or assistant role historical audio input. + /// + public string AudioCorrelationId => _audioReference?.Id ?? _outputAudio?.Id ?? _responseAudioUpdate?.Id; + + /// + /// The timestamp after which the audio associated with is no longer available. + /// + /// + /// Present when is and the content part + /// represents response audio from the service. + /// + public DateTimeOffset? AudioExpiresAt => _outputAudio?.ExpiresAt ?? _responseAudioUpdate?.ExpiresAt; + + /// + /// The transcript that approximates the content of the audio provided by . + /// + /// + /// Present when is and the content part + /// represents response audio from the service. + /// + /// When streaming, this value represents the latest transcript update. + /// + /// + public string AudioTranscript => _outputAudio?.Transcript ?? _responseAudioUpdate?.Transcript; + // CUSTOM: Spread. /// /// The level of detail with which the model should process the image and generate its textual understanding of @@ -88,12 +157,7 @@ public static ChatMessageContentPart CreateTextPart(string text) { Argument.AssertNotNull(text, nameof(text)); - return new ChatMessageContentPart( - kind: ChatMessageContentPartKind.Text, - text: text, - imageUri: null, - refusal: null, - serializedAdditionalRawData: null); + return new ChatMessageContentPart(ChatMessageContentPartKind.Text, text: text); } /// Creates a new that encapsulates an image. @@ -109,10 +173,7 @@ public static ChatMessageContentPart CreateImagePart(Uri imageUri, ChatImageDeta return new ChatMessageContentPart( kind: ChatMessageContentPartKind.Image, - text: null, - imageUri: new(imageUri) { Detail = imageDetailLevel }, - refusal: null, - serializedAdditionalRawData: null); + imageUri: new(imageUri) { Detail = imageDetailLevel }); } /// Creates a new that encapsulates an image. @@ -131,10 +192,7 @@ public static ChatMessageContentPart CreateImagePart(BinaryData imageBytes, stri return new ChatMessageContentPart( kind: ChatMessageContentPartKind.Image, - text: null, - imageUri: new(imageBytes, imageBytesMediaType) { Detail = imageDetailLevel }, - refusal: null, - serializedAdditionalRawData: null); + imageUri: new(imageBytes, imageBytesMediaType) { Detail = imageDetailLevel }); } /// Creates a new that encapsulates a refusal coming from the model. @@ -146,10 +204,39 @@ public static ChatMessageContentPart CreateRefusalPart(string refusal) return new ChatMessageContentPart( kind: ChatMessageContentPartKind.Refusal, - text: null, - imageUri: null, - refusal: refusal, - serializedAdditionalRawData: null); + refusal: refusal); + } + + /// Creates a new that encapsulates user role input audio in a known format. + /// + /// Binary audio content parts may only be used with instances to represent user audio input. When referring to + /// past audio output from the model, use instead. + /// + /// The audio data. + /// The format of the audio data. + public static ChatMessageContentPart CreateAudioPart(BinaryData audioBytes, ChatInputAudioFormat audioFormat) + { + Argument.AssertNotNull(audioBytes, nameof(audioBytes)); + + return new ChatMessageContentPart( + kind: ChatMessageContentPartKind.Audio, + inputAudio: new(audioBytes, audioFormat)); + } + + /// Creates a new that encapsulates an ID-based reference to earlier response audio provided by the model. + /// + /// Reference-based audio content parts are used with instances to represent historical audio output from the model. When providing + /// user audio input, use instead. + /// + /// The unique identifier associated with the audio. + /// is null. + public static ChatMessageContentPart CreateAudioPart(string audioCorrelationId) + { + Argument.AssertNotNull(audioCorrelationId, nameof(audioCorrelationId)); + + return new( + kind: ChatMessageContentPartKind.Audio, + audioReference: new InternalChatCompletionRequestAssistantMessageAudio(audioCorrelationId, null)); } /// @@ -159,4 +246,22 @@ public static ChatMessageContentPart CreateRefusalPart(string refusal) /// /// The text encapsulated by this . public static implicit operator ChatMessageContentPart(string text) => CreateTextPart(text); + + /// + /// Gets a value indicating whether this content part is contrived, in which case it does not represent a valid + /// member of a JSON content array within a REST body. + /// + internal bool IsContrived + { + get + { + // Audio content parts representing ID-based references or response audio are synthesized from dedicated + // "audio" JSON properties. + if (_kind == ChatMessageContentPartKind.Audio && _inputAudio is null) + { + return true; + } + return false; + } + } } diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs index 2ef688cd0..b2d6d397a 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs @@ -13,6 +13,7 @@ internal static partial class ChatMessageContentPartKindExtensions ChatMessageContentPartKind.Text => "text", ChatMessageContentPartKind.Refusal => "refusal", ChatMessageContentPartKind.Image => "image_url", + ChatMessageContentPartKind.Audio => "input_audio", _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageContentPartKind value.") }; @@ -21,6 +22,7 @@ public static ChatMessageContentPartKind ToChatMessageContentPartKind(this strin if (StringComparer.OrdinalIgnoreCase.Equals(value, "text")) return ChatMessageContentPartKind.Text; if (StringComparer.OrdinalIgnoreCase.Equals(value, "refusal")) return ChatMessageContentPartKind.Refusal; if (StringComparer.OrdinalIgnoreCase.Equals(value, "image_url")) return ChatMessageContentPartKind.Image; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_audio")) return ChatMessageContentPartKind.Audio; throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageContentPartKind value."); } } diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.cs index a6cc4f5e4..29c17ccc6 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.cs @@ -9,5 +9,7 @@ public enum ChatMessageContentPartKind Refusal, - Image + Image, + + Audio, } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatOutputAudioFormat.cs b/.dotnet/src/Custom/Chat/ChatOutputAudioFormat.cs new file mode 100644 index 000000000..f82ba8034 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatOutputAudioFormat.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Chat; + +[CodeGenModel("CreateChatCompletionRequestAudioFormat")] +public readonly partial struct ChatOutputAudioFormat +{ + +} diff --git a/.dotnet/src/Custom/Chat/ChatResponseVoice.cs b/.dotnet/src/Custom/Chat/ChatResponseVoice.cs new file mode 100644 index 000000000..ab875e421 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatResponseVoice.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Chat; + +[CodeGenModel("CreateChatCompletionRequestAudioVoice")] +public readonly partial struct ChatResponseVoice +{ + +} diff --git a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs index 660bc6d7e..2f64daf92 100644 --- a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs @@ -94,4 +94,20 @@ internal readonly partial struct InternalCreateChatCompletionStreamResponseServi internal partial class InternalCreateChatCompletionStreamResponseUsage { } [CodeGenModel("FunctionParameters")] -internal partial class InternalFunctionParameters { } \ No newline at end of file +internal partial class InternalFunctionParameters { } + +[CodeGenModel("CreateChatCompletionRequestModality")] +internal readonly partial struct InternalCreateChatCompletionRequestModality { } + +[CodeGenModel("ChatCompletionRequestMessageContentPartAudioType")] +internal readonly partial struct InternalChatCompletionRequestMessageContentPartAudioType { } + +[CodeGenModel("ChatCompletionRequestAssistantMessageAudio")] +internal partial class InternalChatCompletionRequestAssistantMessageAudio { } + +[CodeGenModel("ChatCompletionResponseMessageAudio")] +internal partial class InternalChatCompletionResponseMessageAudio { } + +[CodeGenModel("ChatCompletionMessageAudioChunk")] +internal partial class InternalChatCompletionMessageAudioChunk { } + diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudio.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudio.cs new file mode 100644 index 000000000..0203c71b0 --- /dev/null +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudio.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace OpenAI.Chat; + +[CodeGenModel("ChatCompletionRequestMessageContentPartAudio")] +internal partial class InternalChatCompletionRequestMessageContentPartAudio +{ + +} diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs new file mode 100644 index 000000000..08f25b5e1 --- /dev/null +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace OpenAI.Chat; + +[CodeGenModel("ChatCompletionRequestMessageContentPartAudioInputAudio")] +internal partial class InternalChatCompletionRequestMessageContentPartAudioInputAudio +{ +} diff --git a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs index f4503f98e..aeabf2630 100644 --- a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs +++ b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -22,16 +22,27 @@ public static ChatCompletion ChatCompletion( DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, - ChatTokenUsage usage = null) + ChatTokenUsage usage = null, + BinaryData audioBytes = null, + string audioCorrelationId = null, + string audioTranscript = null, + DateTimeOffset? audioExpiresAt = null) { content ??= new ChatMessageContent(); toolCalls ??= new List(); contentTokenLogProbabilities ??= new List(); refusalTokenLogProbabilities ??= new List(); + InternalChatCompletionResponseMessageAudio audio = null; + if (audioCorrelationId is not null || audioExpiresAt is not null || audioBytes is not null || audioTranscript is not null) + { + audio = new(audioCorrelationId, audioExpiresAt ?? default, audioBytes, audioTranscript); + } + InternalChatCompletionResponseMessage message = new InternalChatCompletionResponseMessage( refusal, toolCalls.ToList(), + audio, role, content, functionCall, @@ -133,14 +144,25 @@ public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate( DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, - ChatTokenUsage usage = null) + ChatTokenUsage usage = null, + string audioCorrelationId = null, + string audioTranscript = null, + BinaryData audioBytes = null, + DateTimeOffset? audioExpiresAt = null) { contentUpdate ??= new ChatMessageContent(); toolCallUpdates ??= new List(); contentTokenLogProbabilities ??= new List(); refusalTokenLogProbabilities ??= new List(); + InternalChatCompletionMessageAudioChunk audio = null; + if (audioCorrelationId is not null || audioTranscript is not null || audioBytes is not null || audioExpiresAt is not null) + { + audio = new(audioCorrelationId, audioTranscript, audioBytes, audioExpiresAt, additionalBinaryDataProperties: null); + } + InternalChatCompletionStreamResponseDelta delta = new InternalChatCompletionStreamResponseDelta( + audio, functionCallUpdate, toolCallUpdates.ToList(), refusalUpdate, diff --git a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs index 54441795b..01a5ec011 100644 --- a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs +++ b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs @@ -93,10 +93,7 @@ public partial class StreamingChatCompletionUpdate /// Each streaming update contains only a small portion of tokens. To reconstitute the entire chat completion, /// all values across streaming updates must be combined. /// - public ChatMessageContent ContentUpdate => - _contentUpdate - ??= InternalChoiceDelta?.Content - ?? new ChatMessageContent(); + public ChatMessageContent ContentUpdate => _contentUpdate ??= GetWrappedContentUpdate(); // CUSTOM: Flattened choice delta property. /// The tool calls generated by the model, such as function calls. @@ -112,4 +109,22 @@ public IReadOnlyList ToolCallUpdates // CUSTOM: Flattened choice delta property. [Obsolete($"This property is obsolete. Please use {nameof(ToolCallUpdates)} instead.")] public StreamingChatFunctionCallUpdate FunctionCallUpdate => InternalChoiceDelta?.FunctionCall; + + private ChatMessageContent GetWrappedContentUpdate() + { + ChatMessageContent wrappedResult = new(); + + if (InternalChoiceDelta?.Audio is not null) + { + wrappedResult.Add(new ChatMessageContentPart( + ChatMessageContentPartKind.Audio, + responseAudioUpdate: InternalChoiceDelta.Audio)); + } + foreach (ChatMessageContentPart deltaContentPart in InternalChoiceDelta?.Content ?? []) + { + wrappedResult.Add(deltaContentPart); + } + + return wrappedResult; + } } diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationItem.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationItem.cs index 7d24f9543..96bc20804 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ConversationItem.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationItem.cs @@ -5,7 +5,7 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")] -[CodeGenModel("RealtimeRequestItem")] +[CodeGenModel("RealtimeConversationRequestItem")] public partial class ConversationItem { public string FunctionCallId => (this as InternalRealtimeRequestFunctionCallItem)?.CallId; diff --git a/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs index 74c2eca27..3b1c192ec 100644 --- a/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs @@ -12,6 +12,7 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")][CodeGenModel("RealtimeClientEventResponseCancel")] internal partial class InternalRealtimeClientEventResponseCancel { } [Experimental("OPENAI002")][CodeGenModel("RealtimeClientEventSessionUpdate")] internal partial class InternalRealtimeClientEventSessionUpdate { } [Experimental("OPENAI002")][CodeGenModel("RealtimeClientEventType")] internal readonly partial struct InternalRealtimeClientEventType { } +[Experimental("OPENAI002")][CodeGenModel("RealtimeConversationResponseItemObject")] internal readonly partial struct InternalRealtimeConversationResponseItemObject { } [Experimental("OPENAI002")][CodeGenModel("RealtimeItemType")] internal readonly partial struct InternalRealtimeItemType { } [Experimental("OPENAI002")][CodeGenModel("RealtimeRequestAudioContentPart")] internal partial class InternalRealtimeRequestAudioContentPart { } [Experimental("OPENAI002")][CodeGenModel("RealtimeRequestFunctionCallItem")] internal partial class InternalRealtimeRequestFunctionCallItem { } @@ -22,7 +23,6 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseAudioContentPart")] internal partial class InternalRealtimeResponseAudioContentPart { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseFunctionCallItem")] internal partial class InternalRealtimeResponseFunctionCallItem { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseFunctionCallOutputItem")] internal partial class InternalRealtimeResponseFunctionCallOutputItem { } -[Experimental("OPENAI002")][CodeGenModel("RealtimeResponseItemObject")] internal readonly partial struct InternalRealtimeResponseItemObject { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseObject")] internal readonly partial struct InternalRealtimeResponseObject { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseSessionObject")] internal readonly partial struct InternalRealtimeResponseSessionObject { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseTextContentPart")] internal partial class InternalRealtimeResponseTextContentPart { } @@ -35,9 +35,9 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")][CodeGenModel("RealtimeToolChoiceObject")] internal partial class InternalRealtimeToolChoiceObject { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeClientEvent")] internal partial class UnknownRealtimeClientEvent { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeContentPart")] internal partial class UnknownRealtimeContentPart { } -[Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeRequestItem")] internal partial class UnknownRealtimeRequestItem { } +[Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeConversationRequestItem")] internal partial class UnknownRealtimeRequestItem { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeRequestMessageItem")] internal partial class UnknownRealtimeRequestMessageItem { } -[Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeResponseItem")] internal partial class UnknownRealtimeResponseItem { } +[Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeConversationResponseItem")] internal partial class UnknownRealtimeResponseItem { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeResponseStatusDetails")] internal partial class UnknownRealtimeResponseStatusDetails { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeServerEvent")] internal partial class UnknownRealtimeServerEvent { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeTool")] internal partial class UnknownRealtimeTool { } diff --git a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeClientEventResponseCreateResponse.cs b/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeClientEventResponseCreateResponse.cs index b4338272c..e6e6112f5 100644 --- a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeClientEventResponseCreateResponse.cs +++ b/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeClientEventResponseCreateResponse.cs @@ -8,13 +8,13 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")] -[CodeGenModel("RealtimeClientEventResponseCreateResponse")] -internal partial class InternalRealtimeClientEventResponseCreateResponse +[CodeGenModel("RealtimeResponseOptions")] +internal partial class InternalRealtimeResponseOptions { [CodeGenMember("ToolChoice")] public BinaryData ToolChoice { get; set; } - public static InternalRealtimeClientEventResponseCreateResponse FromSessionOptions( + public static InternalRealtimeResponseOptions FromSessionOptions( ConversationSessionOptions sessionOptions) { Argument.AssertNotNull(sessionOptions, nameof(sessionOptions)); @@ -28,17 +28,14 @@ public static InternalRealtimeClientEventResponseCreateResponse FromSessionOptio : null; IList internalModalities = sessionOptions.ContentModalities.ToInternalModalities(); - IList rawModalities = internalModalities.Count > 0 - ? internalModalities.Select(modality => modality.ToString()).ToList() - : new ChangeTrackingList(); BinaryData toolChoice = Optional.IsDefined(sessionOptions.ToolChoice) ? ModelReaderWriter.Write(sessionOptions.ToolChoice) : null; - InternalRealtimeClientEventResponseCreateResponse internalOptions = new( - modalities: rawModalities, + InternalRealtimeResponseOptions internalOptions = new( + modalities: internalModalities, instructions: sessionOptions.Instructions, - voice: sessionOptions.Voice?.ToString(), - outputAudioFormat: sessionOptions.OutputAudioFormat?.ToString(), + voice: sessionOptions.Voice, + outputAudioFormat: sessionOptions.OutputAudioFormat, tools: sessionOptions.Tools, toolChoice: toolChoice, temperature: sessionOptions.Temperature, diff --git a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponseItem.cs b/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponseItem.cs index 0679556f0..6dd2e9143 100644 --- a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponseItem.cs +++ b/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponseItem.cs @@ -4,8 +4,8 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")] -[CodeGenModel("RealtimeResponseItem")] -internal partial class InternalRealtimeResponseItem +[CodeGenModel("RealtimeConversationResponseItem")] +internal partial class InternalRealtimeConversationResponseItem { public string ResponseId => (this as InternalRealtimeResponseMessageItem)?.ResponseId diff --git a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponseMessageItem.cs b/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponseMessageItem.cs index a69346981..25dc0c539 100644 --- a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponseMessageItem.cs +++ b/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponseMessageItem.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace OpenAI.RealtimeConversation; @@ -6,6 +7,13 @@ namespace OpenAI.RealtimeConversation; [CodeGenModel("RealtimeResponseMessageItem")] internal partial class InternalRealtimeResponseMessageItem { + // CUSTOM: Use the available strong type for roles. + [CodeGenMember("Role")] public ConversationMessageRole Role { get; } + + // CUSTOM: Explicitly apply response model read-only. + + [CodeGenMember("Content")] + public IReadOnlyList Content { get; } } diff --git a/.dotnet/src/Custom/RealtimeConversation/RealtimeConversationSession.cs b/.dotnet/src/Custom/RealtimeConversation/RealtimeConversationSession.cs index 6ba3f6ab5..07f375398 100644 --- a/.dotnet/src/Custom/RealtimeConversation/RealtimeConversationSession.cs +++ b/.dotnet/src/Custom/RealtimeConversation/RealtimeConversationSession.cs @@ -278,14 +278,14 @@ public virtual void InterruptResponse(CancellationToken cancellationToken = defa public virtual async Task StartResponseAsync(CancellationToken cancellationToken = default) { - InternalRealtimeClientEventResponseCreateResponse internalOptions = new(); + InternalRealtimeResponseOptions internalOptions = new(); InternalRealtimeClientEventResponseCreate internalCommand = new(internalOptions); await SendCommandAsync(internalCommand, cancellationToken).ConfigureAwait(false); } public virtual void StartResponse(CancellationToken cancellationToken = default) { - InternalRealtimeClientEventResponseCreateResponse internalOptions = new(); + InternalRealtimeResponseOptions internalOptions = new(); InternalRealtimeClientEventResponseCreate internalCommand = new(internalOptions); SendCommand(internalCommand, cancellationToken); } @@ -293,8 +293,8 @@ public virtual void StartResponse(CancellationToken cancellationToken = default) public virtual async Task StartResponseAsync(ConversationSessionOptions sessionOptionOverrides, CancellationToken cancellationToken = default) { Argument.AssertNotNull(sessionOptionOverrides, nameof(sessionOptionOverrides)); - InternalRealtimeClientEventResponseCreateResponse internalOptions - = InternalRealtimeClientEventResponseCreateResponse.FromSessionOptions(sessionOptionOverrides); + InternalRealtimeResponseOptions internalOptions + = InternalRealtimeResponseOptions.FromSessionOptions(sessionOptionOverrides); InternalRealtimeClientEventResponseCreate internalCommand = new(internalOptions); await SendCommandAsync(internalCommand, cancellationToken).ConfigureAwait(false); } @@ -302,8 +302,8 @@ InternalRealtimeClientEventResponseCreateResponse internalOptions public virtual void StartResponse(ConversationSessionOptions sessionOptionOverrides, CancellationToken cancellationToken = default) { Argument.AssertNotNull(sessionOptionOverrides, nameof(sessionOptionOverrides)); - InternalRealtimeClientEventResponseCreateResponse internalOptions - = InternalRealtimeClientEventResponseCreateResponse.FromSessionOptions(sessionOptionOverrides); + InternalRealtimeResponseOptions internalOptions + = InternalRealtimeResponseOptions.FromSessionOptions(sessionOptionOverrides); InternalRealtimeClientEventResponseCreate internalCommand = new(internalOptions); SendCommand(internalCommand, cancellationToken); } diff --git a/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemCreatedUpdate.cs b/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemCreatedUpdate.cs index 9b98488e4..ca5600641 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemCreatedUpdate.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemCreatedUpdate.cs @@ -17,7 +17,7 @@ namespace OpenAI.RealtimeConversation; public partial class ConversationItemCreatedUpdate { [CodeGenMember("Item")] - private readonly InternalRealtimeResponseItem _internalItem; + private readonly InternalRealtimeConversationResponseItem _internalItem; public string ItemId => _internalItem.Id; diff --git a/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemStreamingFinishedUpdate.cs b/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemStreamingFinishedUpdate.cs index 86881012d..4f68f7d95 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemStreamingFinishedUpdate.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemStreamingFinishedUpdate.cs @@ -15,7 +15,7 @@ namespace OpenAI.RealtimeConversation; public partial class ConversationItemStreamingFinishedUpdate { [CodeGenMember("Item")] - private readonly InternalRealtimeResponseItem _internalItem; + private readonly InternalRealtimeConversationResponseItem _internalItem; public string ItemId => _internalItem.Id; diff --git a/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemStreamingStartedUpdate.cs b/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemStreamingStartedUpdate.cs index d1d4b538a..a5ce8974e 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemStreamingStartedUpdate.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationItemStreamingStartedUpdate.cs @@ -14,7 +14,7 @@ namespace OpenAI.RealtimeConversation; public partial class ConversationItemStreamingStartedUpdate { [CodeGenMember("Item")] - private readonly InternalRealtimeResponseItem _internalItem; + private readonly InternalRealtimeConversationResponseItem _internalItem; public string ItemId => _internalItem.Id; diff --git a/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs index dd6564373..b4782f168 100644 --- a/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs @@ -5,7 +5,6 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; using OpenAI; @@ -60,6 +59,18 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteNull("functionCall"u8); } } + if (Optional.IsDefined(Audio) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) + { + if (Audio != null) + { + writer.WritePropertyName("audio"u8); + writer.WriteObjectValue(Audio, options); + } + else + { + writer.WriteNull("audio"u8); + } + } } AssistantChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AssistantChatMessage)JsonModelCreateCore(ref reader, options); @@ -72,87 +83,7 @@ protected override ChatMessage JsonModelCreateCore(ref Utf8JsonReader reader, Mo throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAssistantChatMessage(document.RootElement, options); - } - - internal static AssistantChatMessage DeserializeAssistantChatMessage(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - Chat.ChatMessageRole role = default; - ChatMessageContent content = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string refusal = default; - string participantName = default; - IList toolCalls = default; - ChatFunctionCall functionCall = default; - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("role"u8)) - { - role = prop.Value.GetString().ToChatMessageRole(); - continue; - } - if (prop.NameEquals("content"u8)) - { - DeserializeContentValue(prop, ref content); - continue; - } - if (prop.NameEquals("refusal"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - refusal = null; - continue; - } - refusal = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("name"u8)) - { - participantName = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("tool_calls"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in prop.Value.EnumerateArray()) - { - array.Add(ChatToolCall.DeserializeChatToolCall(item, options)); - } - toolCalls = array; - continue; - } - if (prop.NameEquals("function_call"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - functionCall = null; - continue; - } - functionCall = ChatFunctionCall.DeserializeChatFunctionCall(prop.Value, options); - continue; - } - if (true) - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - // CUSTOM: Initialize Content collection property. - return new AssistantChatMessage( - role, - content ?? new ChatMessageContent(), - additionalBinaryDataProperties, - refusal, - participantName, - toolCalls ?? new ChangeTrackingList(), - functionCall); + return AssistantChatMessage.DeserializeAssistantChatMessage(document.RootElement, options); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); @@ -179,7 +110,7 @@ protected override ChatMessage PersistableModelCreateCore(BinaryData data, Model case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeAssistantChatMessage(document.RootElement, options); + return AssistantChatMessage.DeserializeAssistantChatMessage(document.RootElement, options); } default: throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support reading '{options.Format}' format."); @@ -201,7 +132,7 @@ public static explicit operator AssistantChatMessage(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeAssistantChatMessage(document.RootElement, ModelSerializationExtensions.WireOptions); + return AssistantChatMessage.DeserializeAssistantChatMessage(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/AssistantChatMessage.cs b/.dotnet/src/Generated/Models/AssistantChatMessage.cs index e93ddae80..d84662667 100644 --- a/.dotnet/src/Generated/Models/AssistantChatMessage.cs +++ b/.dotnet/src/Generated/Models/AssistantChatMessage.cs @@ -9,12 +9,13 @@ namespace OpenAI.Chat { public partial class AssistantChatMessage : ChatMessage { - internal AssistantChatMessage(Chat.ChatMessageRole role, ChatMessageContent content, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall) : base(role, content, additionalBinaryDataProperties) + internal AssistantChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, InternalChatCompletionRequestAssistantMessageAudio audio) : base(content, role, additionalBinaryDataProperties) { Refusal = refusal; ParticipantName = participantName; ToolCalls = toolCalls; FunctionCall = functionCall; + Audio = audio; } public string Refusal { get; set; } diff --git a/.dotnet/src/Generated/Models/ChatAudioOptions.Serialization.cs b/.dotnet/src/Generated/Models/ChatAudioOptions.Serialization.cs new file mode 100644 index 000000000..8ee8a3b0b --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatAudioOptions.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + public partial class ChatAudioOptions : IJsonModel + { + internal ChatAudioOptions() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatAudioOptions)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("voice") != true) + { + writer.WritePropertyName("voice"u8); + writer.WriteStringValue(ResponseVoice.ToString()); + } + if (_additionalBinaryDataProperties?.ContainsKey("format") != true) + { + writer.WritePropertyName("format"u8); + writer.WriteStringValue(OutputAudioFormat.ToString()); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChatAudioOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual ChatAudioOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatAudioOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatAudioOptions(document.RootElement, options); + } + + internal static ChatAudioOptions DeserializeChatAudioOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ChatResponseVoice responseVoice = default; + ChatOutputAudioFormat outputAudioFormat = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("voice"u8)) + { + responseVoice = new ChatResponseVoice(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("format"u8)) + { + outputAudioFormat = new ChatOutputAudioFormat(prop.Value.GetString()); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChatAudioOptions(responseVoice, outputAudioFormat, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatAudioOptions)} does not support writing '{options.Format}' format."); + } + } + + ChatAudioOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual ChatAudioOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeChatAudioOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatAudioOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(ChatAudioOptions chatAudioOptions) + { + if (chatAudioOptions == null) + { + return null; + } + return BinaryContent.Create(chatAudioOptions, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator ChatAudioOptions(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeChatAudioOptions(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/ChatAudioOptions.cs b/.dotnet/src/Generated/Models/ChatAudioOptions.cs new file mode 100644 index 000000000..129409105 --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatAudioOptions.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Chat +{ + public partial class ChatAudioOptions + { + private protected IDictionary _additionalBinaryDataProperties; + + public ChatAudioOptions(ChatResponseVoice responseVoice, ChatOutputAudioFormat outputAudioFormat) + { + ResponseVoice = responseVoice; + OutputAudioFormat = outputAudioFormat; + } + + internal ChatAudioOptions(ChatResponseVoice responseVoice, ChatOutputAudioFormat outputAudioFormat, IDictionary additionalBinaryDataProperties) + { + ResponseVoice = responseVoice; + OutputAudioFormat = outputAudioFormat; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs index 8f1a29eca..42cdea309 100644 --- a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs @@ -297,6 +297,35 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteNull("serviceTier"u8); } } + if (Optional.IsCollectionDefined(_internalModalities) && _additionalBinaryDataProperties?.ContainsKey("modalities") != true) + { + if (_internalModalities != null) + { + writer.WritePropertyName("modalities"u8); + writer.WriteStartArray(); + foreach (InternalCreateChatCompletionRequestModality item in _internalModalities) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("modalities"u8); + } + } + if (Optional.IsDefined(_audioOptions) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) + { + if (_audioOptions != null) + { + writer.WritePropertyName("audio"u8); + writer.WriteObjectValue(_audioOptions, options); + } + else + { + writer.WriteNull("audio"u8); + } + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -363,6 +392,8 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme IDictionary metadata = default; bool? storedOutputEnabled = default; InternalCreateChatCompletionRequestServiceTier? serviceTier = default; + IList internalModalities = default; + ChatAudioOptions audioOptions = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -621,6 +652,30 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme serviceTier = new InternalCreateChatCompletionRequestServiceTier(prop.Value.GetString()); continue; } + if (prop.NameEquals("modalities"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new InternalCreateChatCompletionRequestModality(item.GetString())); + } + internalModalities = array; + continue; + } + if (prop.NameEquals("audio"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + audioOptions = null; + continue; + } + audioOptions = ChatAudioOptions.DeserializeChatAudioOptions(prop.Value, options); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -653,6 +708,8 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme metadata ?? new ChangeTrackingDictionary(), storedOutputEnabled, serviceTier, + internalModalities, + audioOptions, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/ChatCompletionOptions.cs b/.dotnet/src/Generated/Models/ChatCompletionOptions.cs index 431b4bed0..b5e6dfe2b 100644 --- a/.dotnet/src/Generated/Models/ChatCompletionOptions.cs +++ b/.dotnet/src/Generated/Models/ChatCompletionOptions.cs @@ -11,7 +11,7 @@ public partial class ChatCompletionOptions { private protected IDictionary _additionalBinaryDataProperties; - internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, ChatResponseFormat responseFormat, float? temperature, float? topP, IList tools, IList messages, InternalCreateChatCompletionRequestModel model, int? n, bool? stream, InternalChatCompletionStreamOptions streamOptions, bool? includeLogProbabilities, int? topLogProbabilityCount, IList stopSequences, IDictionary logitBiases, ChatToolChoice toolChoice, ChatFunctionChoice functionChoice, bool? allowParallelToolCalls, string endUserId, long? seed, int? deprecatedMaxTokens, int? maxOutputTokenCount, IList functions, IDictionary metadata, bool? storedOutputEnabled, InternalCreateChatCompletionRequestServiceTier? serviceTier, IDictionary additionalBinaryDataProperties) + internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, ChatResponseFormat responseFormat, float? temperature, float? topP, IList tools, IList messages, InternalCreateChatCompletionRequestModel model, int? n, bool? stream, InternalChatCompletionStreamOptions streamOptions, bool? includeLogProbabilities, int? topLogProbabilityCount, IList stopSequences, IDictionary logitBiases, ChatToolChoice toolChoice, ChatFunctionChoice functionChoice, bool? allowParallelToolCalls, string endUserId, long? seed, int? deprecatedMaxTokens, int? maxOutputTokenCount, IList functions, IDictionary metadata, bool? storedOutputEnabled, InternalCreateChatCompletionRequestServiceTier? serviceTier, IList internalModalities, ChatAudioOptions audioOptions, IDictionary additionalBinaryDataProperties) { FrequencyPenalty = frequencyPenalty; PresencePenalty = presencePenalty; @@ -39,6 +39,8 @@ internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, Metadata = metadata; StoredOutputEnabled = storedOutputEnabled; _serviceTier = serviceTier; + _internalModalities = internalModalities; + _audioOptions = audioOptions; _additionalBinaryDataProperties = additionalBinaryDataProperties; } diff --git a/.dotnet/src/Generated/Models/ChatInputAudioFormat.cs b/.dotnet/src/Generated/Models/ChatInputAudioFormat.cs new file mode 100644 index 000000000..ab86472b5 --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatInputAudioFormat.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + public readonly partial struct ChatInputAudioFormat : IEquatable + { + private readonly string _value; + private const string WavValue = "wav"; + private const string Mp3Value = "mp3"; + + public ChatInputAudioFormat(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static ChatInputAudioFormat Wav { get; } = new ChatInputAudioFormat(WavValue); + + public static ChatInputAudioFormat Mp3 { get; } = new ChatInputAudioFormat(Mp3Value); + + public static bool operator ==(ChatInputAudioFormat left, ChatInputAudioFormat right) => left.Equals(right); + + public static bool operator !=(ChatInputAudioFormat left, ChatInputAudioFormat right) => !left.Equals(right); + + public static implicit operator ChatInputAudioFormat(string value) => new ChatInputAudioFormat(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatInputAudioFormat other && Equals(other); + + public bool Equals(ChatInputAudioFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/ChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/ChatMessage.Serialization.cs index b39d4ef3b..0f27516c0 100644 --- a/.dotnet/src/Generated/Models/ChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatMessage.Serialization.cs @@ -20,17 +20,17 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(ChatMessage)} does not support writing '{format}' format."); } - if (_additionalBinaryDataProperties?.ContainsKey("role") != true) - { - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); - } // CUSTOM: Check inner collection is defined. if (true && Optional.IsDefined(Content) && Content.IsInnerCollectionDefined() && _additionalBinaryDataProperties?.ContainsKey("content") != true) { writer.WritePropertyName("content"u8); this.SerializeContentValue(writer, options); } + if (_additionalBinaryDataProperties?.ContainsKey("role") != true) + { + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToSerialString()); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) diff --git a/.dotnet/src/Generated/Models/ChatMessage.cs b/.dotnet/src/Generated/Models/ChatMessage.cs index 368ee1c8d..89391cdf9 100644 --- a/.dotnet/src/Generated/Models/ChatMessage.cs +++ b/.dotnet/src/Generated/Models/ChatMessage.cs @@ -11,10 +11,10 @@ public partial class ChatMessage { private protected IDictionary _additionalBinaryDataProperties; - internal ChatMessage(Chat.ChatMessageRole role, ChatMessageContent content, IDictionary additionalBinaryDataProperties) + internal ChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties) { - Role = role; Content = content; + Role = role; _additionalBinaryDataProperties = additionalBinaryDataProperties; } diff --git a/.dotnet/src/Generated/Models/ChatOutputAudioFormat.cs b/.dotnet/src/Generated/Models/ChatOutputAudioFormat.cs new file mode 100644 index 000000000..bb9b98365 --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatOutputAudioFormat.cs @@ -0,0 +1,53 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + public readonly partial struct ChatOutputAudioFormat : IEquatable + { + private readonly string _value; + private const string WavValue = "wav"; + private const string Mp3Value = "mp3"; + private const string FlacValue = "flac"; + private const string OpusValue = "opus"; + private const string Pcm16Value = "pcm16"; + + public ChatOutputAudioFormat(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static ChatOutputAudioFormat Wav { get; } = new ChatOutputAudioFormat(WavValue); + + public static ChatOutputAudioFormat Mp3 { get; } = new ChatOutputAudioFormat(Mp3Value); + + public static ChatOutputAudioFormat Flac { get; } = new ChatOutputAudioFormat(FlacValue); + + public static ChatOutputAudioFormat Opus { get; } = new ChatOutputAudioFormat(OpusValue); + + public static ChatOutputAudioFormat Pcm16 { get; } = new ChatOutputAudioFormat(Pcm16Value); + + public static bool operator ==(ChatOutputAudioFormat left, ChatOutputAudioFormat right) => left.Equals(right); + + public static bool operator !=(ChatOutputAudioFormat left, ChatOutputAudioFormat right) => !left.Equals(right); + + public static implicit operator ChatOutputAudioFormat(string value) => new ChatOutputAudioFormat(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatOutputAudioFormat other && Equals(other); + + public bool Equals(ChatOutputAudioFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/ChatResponseVoice.cs b/.dotnet/src/Generated/Models/ChatResponseVoice.cs new file mode 100644 index 000000000..d294da7cb --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatResponseVoice.cs @@ -0,0 +1,56 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + public readonly partial struct ChatResponseVoice : IEquatable + { + private readonly string _value; + private const string AlloyValue = "alloy"; + private const string EchoValue = "echo"; + private const string FableValue = "fable"; + private const string OnyxValue = "onyx"; + private const string NovaValue = "nova"; + private const string ShimmerValue = "shimmer"; + + public ChatResponseVoice(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static ChatResponseVoice Alloy { get; } = new ChatResponseVoice(AlloyValue); + + public static ChatResponseVoice Echo { get; } = new ChatResponseVoice(EchoValue); + + public static ChatResponseVoice Fable { get; } = new ChatResponseVoice(FableValue); + + public static ChatResponseVoice Onyx { get; } = new ChatResponseVoice(OnyxValue); + + public static ChatResponseVoice Nova { get; } = new ChatResponseVoice(NovaValue); + + public static ChatResponseVoice Shimmer { get; } = new ChatResponseVoice(ShimmerValue); + + public static bool operator ==(ChatResponseVoice left, ChatResponseVoice right) => left.Equals(right); + + public static bool operator !=(ChatResponseVoice left, ChatResponseVoice right) => !left.Equals(right); + + public static implicit operator ChatResponseVoice(string value) => new ChatResponseVoice(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatResponseVoice other && Equals(other); + + public bool Equals(ChatResponseVoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/ConversationItemCreatedUpdate.Serialization.cs b/.dotnet/src/Generated/Models/ConversationItemCreatedUpdate.Serialization.cs index 57384093e..62b71004a 100644 --- a/.dotnet/src/Generated/Models/ConversationItemCreatedUpdate.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationItemCreatedUpdate.Serialization.cs @@ -40,7 +40,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (_additionalBinaryDataProperties?.ContainsKey("item") != true) { writer.WritePropertyName("item"u8); - writer.WriteObjectValue(_internalItem, options); + writer.WriteObjectValue(_internalItem, options); } } @@ -67,7 +67,7 @@ internal static ConversationItemCreatedUpdate DeserializeConversationItemCreated RealtimeConversation.ConversationUpdateKind kind = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string previousItemId = default; - InternalRealtimeResponseItem internalItem = default; + InternalRealtimeConversationResponseItem internalItem = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("event_id"u8)) @@ -87,7 +87,7 @@ internal static ConversationItemCreatedUpdate DeserializeConversationItemCreated } if (prop.NameEquals("item"u8)) { - internalItem = InternalRealtimeResponseItem.DeserializeInternalRealtimeResponseItem(prop.Value, options); + internalItem = InternalRealtimeConversationResponseItem.DeserializeInternalRealtimeConversationResponseItem(prop.Value, options); continue; } if (true) diff --git a/.dotnet/src/Generated/Models/ConversationItemCreatedUpdate.cs b/.dotnet/src/Generated/Models/ConversationItemCreatedUpdate.cs index ea9d33b3d..23da0c644 100644 --- a/.dotnet/src/Generated/Models/ConversationItemCreatedUpdate.cs +++ b/.dotnet/src/Generated/Models/ConversationItemCreatedUpdate.cs @@ -9,13 +9,13 @@ namespace OpenAI.RealtimeConversation { public partial class ConversationItemCreatedUpdate : ConversationUpdate { - internal ConversationItemCreatedUpdate(string eventId, string previousItemId, InternalRealtimeResponseItem internalItem) : base(eventId, RealtimeConversation.ConversationUpdateKind.ItemCreated) + internal ConversationItemCreatedUpdate(string eventId, string previousItemId, InternalRealtimeConversationResponseItem internalItem) : base(eventId, RealtimeConversation.ConversationUpdateKind.ItemCreated) { PreviousItemId = previousItemId; _internalItem = internalItem; } - internal ConversationItemCreatedUpdate(string eventId, RealtimeConversation.ConversationUpdateKind kind, IDictionary additionalBinaryDataProperties, string previousItemId, InternalRealtimeResponseItem internalItem) : base(eventId, kind, additionalBinaryDataProperties) + internal ConversationItemCreatedUpdate(string eventId, RealtimeConversation.ConversationUpdateKind kind, IDictionary additionalBinaryDataProperties, string previousItemId, InternalRealtimeConversationResponseItem internalItem) : base(eventId, kind, additionalBinaryDataProperties) { PreviousItemId = previousItemId; _internalItem = internalItem; diff --git a/.dotnet/src/Generated/Models/ConversationItemStreamingFinishedUpdate.Serialization.cs b/.dotnet/src/Generated/Models/ConversationItemStreamingFinishedUpdate.Serialization.cs index 2fc545199..6709cf10b 100644 --- a/.dotnet/src/Generated/Models/ConversationItemStreamingFinishedUpdate.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationItemStreamingFinishedUpdate.Serialization.cs @@ -45,7 +45,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (_additionalBinaryDataProperties?.ContainsKey("item") != true) { writer.WritePropertyName("item"u8); - writer.WriteObjectValue(_internalItem, options); + writer.WriteObjectValue(_internalItem, options); } } @@ -73,7 +73,7 @@ internal static ConversationItemStreamingFinishedUpdate DeserializeConversationI IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string responseId = default; int outputIndex = default; - InternalRealtimeResponseItem internalItem = default; + InternalRealtimeConversationResponseItem internalItem = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("event_id"u8)) @@ -98,7 +98,7 @@ internal static ConversationItemStreamingFinishedUpdate DeserializeConversationI } if (prop.NameEquals("item"u8)) { - internalItem = InternalRealtimeResponseItem.DeserializeInternalRealtimeResponseItem(prop.Value, options); + internalItem = InternalRealtimeConversationResponseItem.DeserializeInternalRealtimeConversationResponseItem(prop.Value, options); continue; } if (true) diff --git a/.dotnet/src/Generated/Models/ConversationItemStreamingFinishedUpdate.cs b/.dotnet/src/Generated/Models/ConversationItemStreamingFinishedUpdate.cs index a178fe402..ab9cf68c8 100644 --- a/.dotnet/src/Generated/Models/ConversationItemStreamingFinishedUpdate.cs +++ b/.dotnet/src/Generated/Models/ConversationItemStreamingFinishedUpdate.cs @@ -9,14 +9,14 @@ namespace OpenAI.RealtimeConversation { public partial class ConversationItemStreamingFinishedUpdate : ConversationUpdate { - internal ConversationItemStreamingFinishedUpdate(string eventId, string responseId, int outputIndex, InternalRealtimeResponseItem internalItem) : base(eventId, RealtimeConversation.ConversationUpdateKind.ItemStreamingFinished) + internal ConversationItemStreamingFinishedUpdate(string eventId, string responseId, int outputIndex, InternalRealtimeConversationResponseItem internalItem) : base(eventId, RealtimeConversation.ConversationUpdateKind.ItemStreamingFinished) { ResponseId = responseId; OutputIndex = outputIndex; _internalItem = internalItem; } - internal ConversationItemStreamingFinishedUpdate(string eventId, RealtimeConversation.ConversationUpdateKind kind, IDictionary additionalBinaryDataProperties, string responseId, int outputIndex, InternalRealtimeResponseItem internalItem) : base(eventId, kind, additionalBinaryDataProperties) + internal ConversationItemStreamingFinishedUpdate(string eventId, RealtimeConversation.ConversationUpdateKind kind, IDictionary additionalBinaryDataProperties, string responseId, int outputIndex, InternalRealtimeConversationResponseItem internalItem) : base(eventId, kind, additionalBinaryDataProperties) { ResponseId = responseId; OutputIndex = outputIndex; diff --git a/.dotnet/src/Generated/Models/ConversationItemStreamingStartedUpdate.Serialization.cs b/.dotnet/src/Generated/Models/ConversationItemStreamingStartedUpdate.Serialization.cs index e0e227030..61d947d1e 100644 --- a/.dotnet/src/Generated/Models/ConversationItemStreamingStartedUpdate.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationItemStreamingStartedUpdate.Serialization.cs @@ -45,7 +45,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (_additionalBinaryDataProperties?.ContainsKey("item") != true) { writer.WritePropertyName("item"u8); - writer.WriteObjectValue(_internalItem, options); + writer.WriteObjectValue(_internalItem, options); } } @@ -73,7 +73,7 @@ internal static ConversationItemStreamingStartedUpdate DeserializeConversationIt IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string responseId = default; int itemIndex = default; - InternalRealtimeResponseItem internalItem = default; + InternalRealtimeConversationResponseItem internalItem = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("event_id"u8)) @@ -98,7 +98,7 @@ internal static ConversationItemStreamingStartedUpdate DeserializeConversationIt } if (prop.NameEquals("item"u8)) { - internalItem = InternalRealtimeResponseItem.DeserializeInternalRealtimeResponseItem(prop.Value, options); + internalItem = InternalRealtimeConversationResponseItem.DeserializeInternalRealtimeConversationResponseItem(prop.Value, options); continue; } if (true) diff --git a/.dotnet/src/Generated/Models/ConversationItemStreamingStartedUpdate.cs b/.dotnet/src/Generated/Models/ConversationItemStreamingStartedUpdate.cs index 227fad3fd..ddb0b6e65 100644 --- a/.dotnet/src/Generated/Models/ConversationItemStreamingStartedUpdate.cs +++ b/.dotnet/src/Generated/Models/ConversationItemStreamingStartedUpdate.cs @@ -9,14 +9,14 @@ namespace OpenAI.RealtimeConversation { public partial class ConversationItemStreamingStartedUpdate : ConversationUpdate { - internal ConversationItemStreamingStartedUpdate(string eventId, string responseId, int itemIndex, InternalRealtimeResponseItem internalItem) : base(eventId, RealtimeConversation.ConversationUpdateKind.ItemStreamingStarted) + internal ConversationItemStreamingStartedUpdate(string eventId, string responseId, int itemIndex, InternalRealtimeConversationResponseItem internalItem) : base(eventId, RealtimeConversation.ConversationUpdateKind.ItemStreamingStarted) { ResponseId = responseId; ItemIndex = itemIndex; _internalItem = internalItem; } - internal ConversationItemStreamingStartedUpdate(string eventId, RealtimeConversation.ConversationUpdateKind kind, IDictionary additionalBinaryDataProperties, string responseId, int itemIndex, InternalRealtimeResponseItem internalItem) : base(eventId, kind, additionalBinaryDataProperties) + internal ConversationItemStreamingStartedUpdate(string eventId, RealtimeConversation.ConversationUpdateKind kind, IDictionary additionalBinaryDataProperties, string responseId, int itemIndex, InternalRealtimeConversationResponseItem internalItem) : base(eventId, kind, additionalBinaryDataProperties) { ResponseId = responseId; ItemIndex = itemIndex; diff --git a/.dotnet/src/Generated/Models/FunctionChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/FunctionChatMessage.Serialization.cs index 0c452e997..ae92c684e 100644 --- a/.dotnet/src/Generated/Models/FunctionChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/FunctionChatMessage.Serialization.cs @@ -51,20 +51,20 @@ internal static FunctionChatMessage DeserializeFunctionChatMessage(JsonElement e { return null; } - Chat.ChatMessageRole role = default; ChatMessageContent content = default; + Chat.ChatMessageRole role = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string functionName = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("role"u8)) + if (prop.NameEquals("content"u8)) { - role = prop.Value.GetString().ToChatMessageRole(); + DeserializeContentValue(prop, ref content); continue; } - if (prop.NameEquals("content"u8)) + if (prop.NameEquals("role"u8)) { - DeserializeContentValue(prop, ref content); + role = prop.Value.GetString().ToChatMessageRole(); continue; } if (prop.NameEquals("name"u8)) @@ -78,7 +78,7 @@ internal static FunctionChatMessage DeserializeFunctionChatMessage(JsonElement e } } // CUSTOM: Initialize Content collection property. - return new FunctionChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties, functionName); + return new FunctionChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties, functionName); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/FunctionChatMessage.cs b/.dotnet/src/Generated/Models/FunctionChatMessage.cs index 688e7abc6..4fa37e086 100644 --- a/.dotnet/src/Generated/Models/FunctionChatMessage.cs +++ b/.dotnet/src/Generated/Models/FunctionChatMessage.cs @@ -9,7 +9,7 @@ namespace OpenAI.Chat { public partial class FunctionChatMessage : ChatMessage { - internal FunctionChatMessage(Chat.ChatMessageRole role, ChatMessageContent content, IDictionary additionalBinaryDataProperties, string functionName) : base(role, content, additionalBinaryDataProperties) + internal FunctionChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string functionName) : base(content, role, additionalBinaryDataProperties) { FunctionName = functionName; } diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.Serialization.cs new file mode 100644 index 000000000..9b3f2429d --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.Serialization.cs @@ -0,0 +1,182 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionMessageAudioChunk : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionMessageAudioChunk)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Id) && _additionalBinaryDataProperties?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(Transcript) && _additionalBinaryDataProperties?.ContainsKey("transcript") != true) + { + writer.WritePropertyName("transcript"u8); + writer.WriteStringValue(Transcript); + } + if (Optional.IsDefined(Data) && _additionalBinaryDataProperties?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data.ToArray(), "D"); + } + if (Optional.IsDefined(ExpiresAt) && _additionalBinaryDataProperties?.ContainsKey("expires_at") != true) + { + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt.Value, "U"); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalChatCompletionMessageAudioChunk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalChatCompletionMessageAudioChunk JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionMessageAudioChunk)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionMessageAudioChunk(document.RootElement, options); + } + + internal static InternalChatCompletionMessageAudioChunk DeserializeInternalChatCompletionMessageAudioChunk(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string transcript = default; + BinaryData data = default; + DateTimeOffset? expiresAt = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("transcript"u8)) + { + transcript = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("data"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + data = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); + continue; + } + if (prop.NameEquals("expires_at"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiresAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalChatCompletionMessageAudioChunk(id, transcript, data, expiresAt, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionMessageAudioChunk)} does not support writing '{options.Format}' format."); + } + } + + InternalChatCompletionMessageAudioChunk IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalChatCompletionMessageAudioChunk PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalChatCompletionMessageAudioChunk(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionMessageAudioChunk)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalChatCompletionMessageAudioChunk internalChatCompletionMessageAudioChunk) + { + if (internalChatCompletionMessageAudioChunk == null) + { + return null; + } + return BinaryContent.Create(internalChatCompletionMessageAudioChunk, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalChatCompletionMessageAudioChunk(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionMessageAudioChunk(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.cs b/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.cs new file mode 100644 index 000000000..bcd9a79b8 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionMessageAudioChunk + { + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalChatCompletionMessageAudioChunk() + { + } + + internal InternalChatCompletionMessageAudioChunk(string id, string transcript, BinaryData data, DateTimeOffset? expiresAt, IDictionary additionalBinaryDataProperties) + { + Id = id; + Transcript = transcript; + Data = data; + ExpiresAt = expiresAt; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public string Id { get; } + + public string Transcript { get; } + + public BinaryData Data { get; } + + public DateTimeOffset? ExpiresAt { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.Serialization.cs new file mode 100644 index 000000000..ffc87fbb0 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.Serialization.cs @@ -0,0 +1,145 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionRequestAssistantMessageAudio : IJsonModel + { + internal InternalChatCompletionRequestAssistantMessageAudio() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionRequestAssistantMessageAudio)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalChatCompletionRequestAssistantMessageAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalChatCompletionRequestAssistantMessageAudio JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionRequestAssistantMessageAudio)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionRequestAssistantMessageAudio(document.RootElement, options); + } + + internal static InternalChatCompletionRequestAssistantMessageAudio DeserializeInternalChatCompletionRequestAssistantMessageAudio(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalChatCompletionRequestAssistantMessageAudio(id, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestAssistantMessageAudio)} does not support writing '{options.Format}' format."); + } + } + + InternalChatCompletionRequestAssistantMessageAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalChatCompletionRequestAssistantMessageAudio PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalChatCompletionRequestAssistantMessageAudio(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestAssistantMessageAudio)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalChatCompletionRequestAssistantMessageAudio internalChatCompletionRequestAssistantMessageAudio) + { + if (internalChatCompletionRequestAssistantMessageAudio == null) + { + return null; + } + return BinaryContent.Create(internalChatCompletionRequestAssistantMessageAudio, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalChatCompletionRequestAssistantMessageAudio(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionRequestAssistantMessageAudio(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.cs b/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.cs new file mode 100644 index 000000000..9976eda78 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionRequestAssistantMessageAudio + { + private protected IDictionary _additionalBinaryDataProperties; + + public InternalChatCompletionRequestAssistantMessageAudio(string id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + internal InternalChatCompletionRequestAssistantMessageAudio(string id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public string Id { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudio.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudio.Serialization.cs new file mode 100644 index 000000000..4066d42a3 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudio.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionRequestMessageContentPartAudio : IJsonModel + { + internal InternalChatCompletionRequestMessageContentPartAudio() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartAudio)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (_additionalBinaryDataProperties?.ContainsKey("input_audio") != true) + { + writer.WritePropertyName("input_audio"u8); + writer.WriteObjectValue(InputAudio, options); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalChatCompletionRequestMessageContentPartAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalChatCompletionRequestMessageContentPartAudio JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartAudio)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionRequestMessageContentPartAudio(document.RootElement, options); + } + + internal static InternalChatCompletionRequestMessageContentPartAudio DeserializeInternalChatCompletionRequestMessageContentPartAudio(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalChatCompletionRequestMessageContentPartAudioType @type = default; + InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalChatCompletionRequestMessageContentPartAudioType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("input_audio"u8)) + { + inputAudio = InternalChatCompletionRequestMessageContentPartAudioInputAudio.DeserializeInternalChatCompletionRequestMessageContentPartAudioInputAudio(prop.Value, options); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalChatCompletionRequestMessageContentPartAudio(@type, inputAudio, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartAudio)} does not support writing '{options.Format}' format."); + } + } + + InternalChatCompletionRequestMessageContentPartAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalChatCompletionRequestMessageContentPartAudio PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalChatCompletionRequestMessageContentPartAudio(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartAudio)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalChatCompletionRequestMessageContentPartAudio internalChatCompletionRequestMessageContentPartAudio) + { + if (internalChatCompletionRequestMessageContentPartAudio == null) + { + return null; + } + return BinaryContent.Create(internalChatCompletionRequestMessageContentPartAudio, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalChatCompletionRequestMessageContentPartAudio(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionRequestMessageContentPartAudio(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudio.cs b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudio.cs new file mode 100644 index 000000000..c1d6b3edf --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudio.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionRequestMessageContentPartAudio + { + private protected IDictionary _additionalBinaryDataProperties; + + public InternalChatCompletionRequestMessageContentPartAudio(InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio) + { + Argument.AssertNotNull(inputAudio, nameof(inputAudio)); + + InputAudio = inputAudio; + } + + internal InternalChatCompletionRequestMessageContentPartAudio(InternalChatCompletionRequestMessageContentPartAudioType @type, InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio, IDictionary additionalBinaryDataProperties) + { + Type = @type; + InputAudio = inputAudio; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public InternalChatCompletionRequestMessageContentPartAudioType Type { get; } = "input_audio"; + + public InternalChatCompletionRequestMessageContentPartAudioInputAudio InputAudio { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioInputAudio.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioInputAudio.Serialization.cs new file mode 100644 index 000000000..99ed0481a --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioInputAudio.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionRequestMessageContentPartAudioInputAudio : IJsonModel + { + internal InternalChatCompletionRequestMessageContentPartAudioInputAudio() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartAudioInputAudio)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data.ToArray(), "D"); + } + if (_additionalBinaryDataProperties?.ContainsKey("format") != true) + { + writer.WritePropertyName("format"u8); + writer.WriteStringValue(Format.ToString()); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalChatCompletionRequestMessageContentPartAudioInputAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalChatCompletionRequestMessageContentPartAudioInputAudio JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartAudioInputAudio)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionRequestMessageContentPartAudioInputAudio(document.RootElement, options); + } + + internal static InternalChatCompletionRequestMessageContentPartAudioInputAudio DeserializeInternalChatCompletionRequestMessageContentPartAudioInputAudio(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData data = default; + ChatInputAudioFormat format = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("data"u8)) + { + data = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); + continue; + } + if (prop.NameEquals("format"u8)) + { + format = new ChatInputAudioFormat(prop.Value.GetString()); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalChatCompletionRequestMessageContentPartAudioInputAudio(data, format, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartAudioInputAudio)} does not support writing '{options.Format}' format."); + } + } + + InternalChatCompletionRequestMessageContentPartAudioInputAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalChatCompletionRequestMessageContentPartAudioInputAudio PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalChatCompletionRequestMessageContentPartAudioInputAudio(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartAudioInputAudio)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalChatCompletionRequestMessageContentPartAudioInputAudio internalChatCompletionRequestMessageContentPartAudioInputAudio) + { + if (internalChatCompletionRequestMessageContentPartAudioInputAudio == null) + { + return null; + } + return BinaryContent.Create(internalChatCompletionRequestMessageContentPartAudioInputAudio, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalChatCompletionRequestMessageContentPartAudioInputAudio(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionRequestMessageContentPartAudioInputAudio(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs new file mode 100644 index 000000000..f490ce017 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionRequestMessageContentPartAudioInputAudio + { + private protected IDictionary _additionalBinaryDataProperties; + + public InternalChatCompletionRequestMessageContentPartAudioInputAudio(BinaryData data, ChatInputAudioFormat format) + { + Argument.AssertNotNull(data, nameof(data)); + + Data = data; + Format = format; + } + + internal InternalChatCompletionRequestMessageContentPartAudioInputAudio(BinaryData data, ChatInputAudioFormat format, IDictionary additionalBinaryDataProperties) + { + Data = data; + Format = format; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public BinaryData Data { get; } + + public ChatInputAudioFormat Format { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioType.cs b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioType.cs new file mode 100644 index 000000000..e7d2eb1b6 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionRequestMessageContentPartAudioType.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + internal readonly partial struct InternalChatCompletionRequestMessageContentPartAudioType : IEquatable + { + private readonly string _value; + private const string InputAudioValue = "input_audio"; + + public InternalChatCompletionRequestMessageContentPartAudioType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalChatCompletionRequestMessageContentPartAudioType InputAudio { get; } = new InternalChatCompletionRequestMessageContentPartAudioType(InputAudioValue); + + public static bool operator ==(InternalChatCompletionRequestMessageContentPartAudioType left, InternalChatCompletionRequestMessageContentPartAudioType right) => left.Equals(right); + + public static bool operator !=(InternalChatCompletionRequestMessageContentPartAudioType left, InternalChatCompletionRequestMessageContentPartAudioType right) => !left.Equals(right); + + public static implicit operator InternalChatCompletionRequestMessageContentPartAudioType(string value) => new InternalChatCompletionRequestMessageContentPartAudioType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalChatCompletionRequestMessageContentPartAudioType other && Equals(other); + + public bool Equals(InternalChatCompletionRequestMessageContentPartAudioType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs index 9f3af8c10..25f435f56 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs @@ -53,6 +53,18 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WriteEndArray(); } + if (Optional.IsDefined(Audio) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) + { + if (Audio != null) + { + writer.WritePropertyName("audio"u8); + writer.WriteObjectValue(Audio, options); + } + else + { + writer.WriteNull("audio"u8); + } + } if (_additionalBinaryDataProperties?.ContainsKey("role") != true) { writer.WritePropertyName("role"u8); @@ -117,6 +129,7 @@ internal static InternalChatCompletionResponseMessage DeserializeInternalChatCom } string refusal = default; IReadOnlyList toolCalls = default; + InternalChatCompletionResponseMessageAudio audio = default; Chat.ChatMessageRole role = default; ChatMessageContent content = default; ChatFunctionCall functionCall = default; @@ -147,6 +160,16 @@ internal static InternalChatCompletionResponseMessage DeserializeInternalChatCom toolCalls = array; continue; } + if (prop.NameEquals("audio"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + audio = null; + continue; + } + audio = InternalChatCompletionResponseMessageAudio.DeserializeInternalChatCompletionResponseMessageAudio(prop.Value, options); + continue; + } if (prop.NameEquals("role"u8)) { role = prop.Value.GetString().ToChatMessageRole(); @@ -175,6 +198,7 @@ internal static InternalChatCompletionResponseMessage DeserializeInternalChatCom return new InternalChatCompletionResponseMessage( refusal, toolCalls ?? new ChangeTrackingList(), + audio, role, content ?? new ChatMessageContent(), functionCall, diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs index 97b362414..0afef0e57 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs @@ -19,10 +19,11 @@ internal InternalChatCompletionResponseMessage(string refusal, ChatMessageConten Content = content; } - internal InternalChatCompletionResponseMessage(string refusal, IReadOnlyList toolCalls, Chat.ChatMessageRole role, ChatMessageContent content, ChatFunctionCall functionCall, IDictionary additionalBinaryDataProperties) + internal InternalChatCompletionResponseMessage(string refusal, IReadOnlyList toolCalls, InternalChatCompletionResponseMessageAudio audio, Chat.ChatMessageRole role, ChatMessageContent content, ChatFunctionCall functionCall, IDictionary additionalBinaryDataProperties) { Refusal = refusal; ToolCalls = toolCalls; + Audio = audio; Role = role; Content = content; FunctionCall = functionCall; @@ -33,6 +34,8 @@ internal InternalChatCompletionResponseMessage(string refusal, IReadOnlyList ToolCalls { get; } + public InternalChatCompletionResponseMessageAudio Audio { get; } + internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.Serialization.cs new file mode 100644 index 000000000..83bbc49e6 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.Serialization.cs @@ -0,0 +1,178 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionResponseMessageAudio : IJsonModel + { + internal InternalChatCompletionResponseMessageAudio() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageAudio)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (_additionalBinaryDataProperties?.ContainsKey("expires_at") != true) + { + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt, "U"); + } + if (_additionalBinaryDataProperties?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data.ToArray(), "D"); + } + if (_additionalBinaryDataProperties?.ContainsKey("transcript") != true) + { + writer.WritePropertyName("transcript"u8); + writer.WriteStringValue(Transcript); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalChatCompletionResponseMessageAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalChatCompletionResponseMessageAudio JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageAudio)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionResponseMessageAudio(document.RootElement, options); + } + + internal static InternalChatCompletionResponseMessageAudio DeserializeInternalChatCompletionResponseMessageAudio(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + DateTimeOffset expiresAt = default; + BinaryData data = default; + string transcript = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("expires_at"u8)) + { + expiresAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("data"u8)) + { + data = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); + continue; + } + if (prop.NameEquals("transcript"u8)) + { + transcript = prop.Value.GetString(); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalChatCompletionResponseMessageAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageAudio)} does not support writing '{options.Format}' format."); + } + } + + InternalChatCompletionResponseMessageAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalChatCompletionResponseMessageAudio PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalChatCompletionResponseMessageAudio(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageAudio)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalChatCompletionResponseMessageAudio internalChatCompletionResponseMessageAudio) + { + if (internalChatCompletionResponseMessageAudio == null) + { + return null; + } + return BinaryContent.Create(internalChatCompletionResponseMessageAudio, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalChatCompletionResponseMessageAudio(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionResponseMessageAudio(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.cs b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.cs new file mode 100644 index 000000000..28ce7fb60 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Chat +{ + internal partial class InternalChatCompletionResponseMessageAudio + { + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalChatCompletionResponseMessageAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript) + { + Id = id; + ExpiresAt = expiresAt; + Data = data; + Transcript = transcript; + } + + internal InternalChatCompletionResponseMessageAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript, IDictionary additionalBinaryDataProperties) + { + Id = id; + ExpiresAt = expiresAt; + Data = data; + Transcript = transcript; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public string Id { get; } + + public DateTimeOffset ExpiresAt { get; } + + public BinaryData Data { get; } + + public string Transcript { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs index e67571f75..e7d9267ba 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs @@ -27,6 +27,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(InternalChatCompletionStreamResponseDelta)} does not support writing '{format}' format."); } + if (Optional.IsDefined(Audio) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) + { + writer.WritePropertyName("audio"u8); + writer.WriteObjectValue(Audio, options); + } if (Optional.IsDefined(FunctionCall) && _additionalBinaryDataProperties?.ContainsKey("function_call") != true) { writer.WritePropertyName("function_call"u8); @@ -112,6 +117,7 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha { return null; } + InternalChatCompletionMessageAudioChunk audio = default; StreamingChatFunctionCallUpdate functionCall = default; IReadOnlyList toolCalls = default; string refusal = default; @@ -120,6 +126,15 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { + if (prop.NameEquals("audio"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + audio = InternalChatCompletionMessageAudioChunk.DeserializeInternalChatCompletionMessageAudioChunk(prop.Value, options); + continue; + } if (prop.NameEquals("function_call"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) @@ -174,6 +189,7 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha } // CUSTOM: Initialize Content collection property. return new InternalChatCompletionStreamResponseDelta( + audio, functionCall, toolCalls ?? new ChangeTrackingList(), refusal, diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs index dba391eaf..14dd3ca44 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs @@ -11,8 +11,9 @@ internal partial class InternalChatCompletionStreamResponseDelta { private protected IDictionary _additionalBinaryDataProperties; - internal InternalChatCompletionStreamResponseDelta(StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, string refusal, Chat.ChatMessageRole? role, ChatMessageContent content, IDictionary additionalBinaryDataProperties) + internal InternalChatCompletionStreamResponseDelta(InternalChatCompletionMessageAudioChunk audio, StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, string refusal, Chat.ChatMessageRole? role, ChatMessageContent content, IDictionary additionalBinaryDataProperties) { + Audio = audio; FunctionCall = functionCall; ToolCalls = toolCalls; Refusal = refusal; @@ -21,6 +22,8 @@ internal InternalChatCompletionStreamResponseDelta(StreamingChatFunctionCallUpda _additionalBinaryDataProperties = additionalBinaryDataProperties; } + public InternalChatCompletionMessageAudioChunk Audio { get; } + public StreamingChatFunctionCallUpdate FunctionCall { get; } public IReadOnlyList ToolCalls { get; } diff --git a/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModality.cs b/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModality.cs new file mode 100644 index 000000000..a0cb97dcc --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModality.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + internal readonly partial struct InternalCreateChatCompletionRequestModality : IEquatable + { + private readonly string _value; + private const string TextValue = "text"; + private const string AudioValue = "audio"; + + public InternalCreateChatCompletionRequestModality(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalCreateChatCompletionRequestModality Text { get; } = new InternalCreateChatCompletionRequestModality(TextValue); + + public static InternalCreateChatCompletionRequestModality Audio { get; } = new InternalCreateChatCompletionRequestModality(AudioValue); + + public static bool operator ==(InternalCreateChatCompletionRequestModality left, InternalCreateChatCompletionRequestModality right) => left.Equals(right); + + public static bool operator !=(InternalCreateChatCompletionRequestModality left, InternalCreateChatCompletionRequestModality right) => !left.Equals(right); + + public static implicit operator InternalCreateChatCompletionRequestModality(string value) => new InternalCreateChatCompletionRequestModality(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionRequestModality other && Equals(other); + + public bool Equals(InternalCreateChatCompletionRequestModality other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs b/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs index f8e62d274..4afaa705b 100644 --- a/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs +++ b/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs @@ -20,6 +20,8 @@ namespace OpenAI.Chat private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; private const string Gpt4oRealtimePreviewValue = "gpt-4o-realtime-preview"; private const string Gpt4oRealtimePreview20241001Value = "gpt-4o-realtime-preview-2024-10-01"; + private const string Gpt4oAudioPreviewValue = "gpt-4o-audio-preview"; + private const string Gpt4oAudioPreview20241001Value = "gpt-4o-audio-preview-2024-10-01"; private const string Chatgpt4oLatestValue = "chatgpt-4o-latest"; private const string Gpt4oMiniValue = "gpt-4o-mini"; private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; @@ -68,6 +70,10 @@ public InternalCreateChatCompletionRequestModel(string value) public static InternalCreateChatCompletionRequestModel Gpt4oRealtimePreview20241001 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oRealtimePreview20241001Value); + public static InternalCreateChatCompletionRequestModel Gpt4oAudioPreview { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oAudioPreviewValue); + + public static InternalCreateChatCompletionRequestModel Gpt4oAudioPreview20241001 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oAudioPreview20241001Value); + public static InternalCreateChatCompletionRequestModel Chatgpt4oLatest { get; } = new InternalCreateChatCompletionRequestModel(Chatgpt4oLatestValue); public static InternalCreateChatCompletionRequestModel Gpt4oMini { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oMiniValue); diff --git a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs index 98cf117e0..8b1a2c459 100644 --- a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs @@ -50,23 +50,24 @@ internal static InternalFineTuneChatCompletionRequestAssistantMessage Deserializ { return null; } - Chat.ChatMessageRole role = default; ChatMessageContent content = default; + Chat.ChatMessageRole role = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string refusal = default; string participantName = default; IList toolCalls = default; ChatFunctionCall functionCall = default; + InternalChatCompletionRequestAssistantMessageAudio audio = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("role"u8)) + if (prop.NameEquals("content"u8)) { - role = prop.Value.GetString().ToChatMessageRole(); + DeserializeContentValue(prop, ref content); continue; } - if (prop.NameEquals("content"u8)) + if (prop.NameEquals("role"u8)) { - DeserializeContentValue(prop, ref content); + role = prop.Value.GetString().ToChatMessageRole(); continue; } if (prop.NameEquals("refusal"u8)) @@ -108,6 +109,16 @@ internal static InternalFineTuneChatCompletionRequestAssistantMessage Deserializ functionCall = ChatFunctionCall.DeserializeChatFunctionCall(prop.Value, options); continue; } + if (prop.NameEquals("audio"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + audio = null; + continue; + } + audio = InternalChatCompletionRequestAssistantMessageAudio.DeserializeInternalChatCompletionRequestAssistantMessageAudio(prop.Value, options); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -115,13 +126,14 @@ internal static InternalFineTuneChatCompletionRequestAssistantMessage Deserializ } // CUSTOM: Initialize Content collection property. return new InternalFineTuneChatCompletionRequestAssistantMessage( - role, content ?? new ChatMessageContent(), + role, additionalBinaryDataProperties, refusal, participantName, toolCalls ?? new ChangeTrackingList(), - functionCall); + functionCall, + audio); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs index 868aa7ef7..85bdc8549 100644 --- a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs +++ b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs @@ -14,7 +14,7 @@ public InternalFineTuneChatCompletionRequestAssistantMessage() { } - internal InternalFineTuneChatCompletionRequestAssistantMessage(Chat.ChatMessageRole role, ChatMessageContent content, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall) : base(role, content, additionalBinaryDataProperties, refusal, participantName, toolCalls, functionCall) + internal InternalFineTuneChatCompletionRequestAssistantMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, InternalChatCompletionRequestAssistantMessageAudio audio) : base(content, role, additionalBinaryDataProperties, refusal, participantName, toolCalls, functionCall, audio) { } } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.Serialization.cs index f1c98f3c9..862ee53db 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.Serialization.cs @@ -61,7 +61,7 @@ internal static InternalRealtimeClientEventResponseCreate DeserializeInternalRea InternalRealtimeClientEventType kind = default; string eventId = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - InternalRealtimeClientEventResponseCreateResponse response = default; + InternalRealtimeResponseOptions response = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) @@ -76,7 +76,7 @@ internal static InternalRealtimeClientEventResponseCreate DeserializeInternalRea } if (prop.NameEquals("response"u8)) { - response = InternalRealtimeClientEventResponseCreateResponse.DeserializeInternalRealtimeClientEventResponseCreateResponse(prop.Value, options); + response = InternalRealtimeResponseOptions.DeserializeInternalRealtimeResponseOptions(prop.Value, options); continue; } if (true) diff --git a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.cs b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.cs index 349d8e180..abdc82c41 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.cs @@ -10,18 +10,18 @@ namespace OpenAI.RealtimeConversation { internal partial class InternalRealtimeClientEventResponseCreate : InternalRealtimeClientEvent { - public InternalRealtimeClientEventResponseCreate(InternalRealtimeClientEventResponseCreateResponse response) : base(InternalRealtimeClientEventType.ResponseCreate) + public InternalRealtimeClientEventResponseCreate(InternalRealtimeResponseOptions response) : base(InternalRealtimeClientEventType.ResponseCreate) { Argument.AssertNotNull(response, nameof(response)); Response = response; } - internal InternalRealtimeClientEventResponseCreate(InternalRealtimeClientEventType kind, string eventId, IDictionary additionalBinaryDataProperties, InternalRealtimeClientEventResponseCreateResponse response) : base(kind, eventId, additionalBinaryDataProperties) + internal InternalRealtimeClientEventResponseCreate(InternalRealtimeClientEventType kind, string eventId, IDictionary additionalBinaryDataProperties, InternalRealtimeResponseOptions response) : base(kind, eventId, additionalBinaryDataProperties) { Response = response; } - public InternalRealtimeClientEventResponseCreateResponse Response { get; } + public InternalRealtimeResponseOptions Response { get; } } } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseItem.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeConversationResponseItem.Serialization.cs similarity index 61% rename from .dotnet/src/Generated/Models/InternalRealtimeResponseItem.Serialization.cs rename to .dotnet/src/Generated/Models/InternalRealtimeConversationResponseItem.Serialization.cs index 8511388a3..214e631d8 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseItem.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeConversationResponseItem.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.RealtimeConversation { [PersistableModelProxy(typeof(UnknownRealtimeResponseItem))] - internal abstract partial class InternalRealtimeResponseItem : IJsonModel + internal abstract partial class InternalRealtimeConversationResponseItem : IJsonModel { - internal InternalRealtimeResponseItem() + internal InternalRealtimeConversationResponseItem() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalRealtimeResponseItem)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeConversationResponseItem)} does not support writing '{format}' format."); } if (_additionalBinaryDataProperties?.ContainsKey("object") != true) { @@ -74,20 +74,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalRealtimeResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + InternalRealtimeConversationResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual InternalRealtimeResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual InternalRealtimeConversationResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalRealtimeResponseItem)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeConversationResponseItem)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRealtimeResponseItem(document.RootElement, options); + return DeserializeInternalRealtimeConversationResponseItem(document.RootElement, options); } - internal static InternalRealtimeResponseItem DeserializeInternalRealtimeResponseItem(JsonElement element, ModelReaderWriterOptions options) + internal static InternalRealtimeConversationResponseItem DeserializeInternalRealtimeConversationResponseItem(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -108,53 +108,53 @@ internal static InternalRealtimeResponseItem DeserializeInternalRealtimeResponse return UnknownRealtimeResponseItem.DeserializeUnknownRealtimeResponseItem(element, options); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalRealtimeResponseItem)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeConversationResponseItem)} does not support writing '{options.Format}' format."); } } - InternalRealtimeResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + InternalRealtimeConversationResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual InternalRealtimeResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual InternalRealtimeConversationResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalRealtimeResponseItem(document.RootElement, options); + return DeserializeInternalRealtimeConversationResponseItem(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalRealtimeResponseItem)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeConversationResponseItem)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalRealtimeResponseItem internalRealtimeResponseItem) + public static implicit operator BinaryContent(InternalRealtimeConversationResponseItem internalRealtimeConversationResponseItem) { - if (internalRealtimeResponseItem == null) + if (internalRealtimeConversationResponseItem == null) { return null; } - return BinaryContent.Create(internalRealtimeResponseItem, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(internalRealtimeConversationResponseItem, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalRealtimeResponseItem(ClientResult result) + public static explicit operator InternalRealtimeConversationResponseItem(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalRealtimeResponseItem(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeInternalRealtimeConversationResponseItem(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseItem.cs b/.dotnet/src/Generated/Models/InternalRealtimeConversationResponseItem.cs similarity index 60% rename from .dotnet/src/Generated/Models/InternalRealtimeResponseItem.cs rename to .dotnet/src/Generated/Models/InternalRealtimeConversationResponseItem.cs index a8ed46d55..c9ba6aa6e 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseItem.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeConversationResponseItem.cs @@ -7,17 +7,17 @@ namespace OpenAI.RealtimeConversation { - internal abstract partial class InternalRealtimeResponseItem + internal abstract partial class InternalRealtimeConversationResponseItem { private protected IDictionary _additionalBinaryDataProperties; - private protected InternalRealtimeResponseItem(InternalRealtimeItemType @type, string id) + private protected InternalRealtimeConversationResponseItem(InternalRealtimeItemType @type, string id) { Type = @type; Id = id; } - internal InternalRealtimeResponseItem(InternalRealtimeResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties) + internal InternalRealtimeConversationResponseItem(InternalRealtimeConversationResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties) { Object = @object; Type = @type; @@ -25,7 +25,7 @@ internal InternalRealtimeResponseItem(InternalRealtimeResponseItemObject @object _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public InternalRealtimeResponseItemObject Object { get; } = "realtime.item"; + public InternalRealtimeConversationResponseItemObject Object { get; } = "realtime.item"; internal InternalRealtimeItemType Type { get; set; } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeConversationResponseItemObject.cs b/.dotnet/src/Generated/Models/InternalRealtimeConversationResponseItemObject.cs new file mode 100644 index 000000000..1d2497d7c --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRealtimeConversationResponseItemObject.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + internal readonly partial struct InternalRealtimeConversationResponseItemObject : IEquatable + { + private readonly string _value; + private const string RealtimeItemValue = "realtime.item"; + + public InternalRealtimeConversationResponseItemObject(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalRealtimeConversationResponseItemObject RealtimeItem { get; } = new InternalRealtimeConversationResponseItemObject(RealtimeItemValue); + + public static bool operator ==(InternalRealtimeConversationResponseItemObject left, InternalRealtimeConversationResponseItemObject right) => left.Equals(right); + + public static bool operator !=(InternalRealtimeConversationResponseItemObject left, InternalRealtimeConversationResponseItemObject right) => !left.Equals(right); + + public static implicit operator InternalRealtimeConversationResponseItemObject(string value) => new InternalRealtimeConversationResponseItemObject(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRealtimeConversationResponseItemObject other && Equals(other); + + public bool Equals(InternalRealtimeConversationResponseItemObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallItem.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallItem.Serialization.cs index 14c3d3388..5af5037d7 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallItem.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallItem.Serialization.cs @@ -56,7 +56,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri InternalRealtimeResponseFunctionCallItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalRealtimeResponseFunctionCallItem)JsonModelCreateCore(ref reader, options); - protected override InternalRealtimeResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected override InternalRealtimeConversationResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -73,7 +73,7 @@ internal static InternalRealtimeResponseFunctionCallItem DeserializeInternalReal { return null; } - InternalRealtimeResponseItemObject @object = default; + InternalRealtimeConversationResponseItemObject @object = default; InternalRealtimeItemType @type = default; string id = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); @@ -85,7 +85,7 @@ internal static InternalRealtimeResponseFunctionCallItem DeserializeInternalReal { if (prop.NameEquals("object"u8)) { - @object = new InternalRealtimeResponseItemObject(prop.Value.GetString()); + @object = new InternalRealtimeConversationResponseItemObject(prop.Value.GetString()); continue; } if (prop.NameEquals("type"u8)) @@ -155,7 +155,7 @@ protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions InternalRealtimeResponseFunctionCallItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalRealtimeResponseFunctionCallItem)PersistableModelCreateCore(data, options); - protected override InternalRealtimeResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected override InternalRealtimeConversationResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallItem.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallItem.cs index e1d10fa80..f89f19c94 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallItem.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallItem.cs @@ -7,7 +7,7 @@ namespace OpenAI.RealtimeConversation { - internal partial class InternalRealtimeResponseFunctionCallItem : InternalRealtimeResponseItem + internal partial class InternalRealtimeResponseFunctionCallItem : InternalRealtimeConversationResponseItem { internal InternalRealtimeResponseFunctionCallItem(string id, string name, string callId, string arguments, ConversationItemStatus status) : base(InternalRealtimeItemType.FunctionCall, id) { @@ -17,7 +17,7 @@ internal InternalRealtimeResponseFunctionCallItem(string id, string name, string Status = status; } - internal InternalRealtimeResponseFunctionCallItem(InternalRealtimeResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties, string name, string callId, string arguments, ConversationItemStatus status) : base(@object, @type, id, additionalBinaryDataProperties) + internal InternalRealtimeResponseFunctionCallItem(InternalRealtimeConversationResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties, string name, string callId, string arguments, ConversationItemStatus status) : base(@object, @type, id, additionalBinaryDataProperties) { Name = name; CallId = callId; diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallOutputItem.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallOutputItem.Serialization.cs index c5b563a3d..d7e539a5d 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallOutputItem.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallOutputItem.Serialization.cs @@ -46,7 +46,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri InternalRealtimeResponseFunctionCallOutputItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalRealtimeResponseFunctionCallOutputItem)JsonModelCreateCore(ref reader, options); - protected override InternalRealtimeResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected override InternalRealtimeConversationResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -63,7 +63,7 @@ internal static InternalRealtimeResponseFunctionCallOutputItem DeserializeIntern { return null; } - InternalRealtimeResponseItemObject @object = default; + InternalRealtimeConversationResponseItemObject @object = default; InternalRealtimeItemType @type = default; string id = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); @@ -73,7 +73,7 @@ internal static InternalRealtimeResponseFunctionCallOutputItem DeserializeIntern { if (prop.NameEquals("object"u8)) { - @object = new InternalRealtimeResponseItemObject(prop.Value.GetString()); + @object = new InternalRealtimeConversationResponseItemObject(prop.Value.GetString()); continue; } if (prop.NameEquals("type"u8)) @@ -131,7 +131,7 @@ protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions InternalRealtimeResponseFunctionCallOutputItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalRealtimeResponseFunctionCallOutputItem)PersistableModelCreateCore(data, options); - protected override InternalRealtimeResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected override InternalRealtimeConversationResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallOutputItem.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallOutputItem.cs index 7295ba6f7..babadf19c 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallOutputItem.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseFunctionCallOutputItem.cs @@ -7,7 +7,7 @@ namespace OpenAI.RealtimeConversation { - internal partial class InternalRealtimeResponseFunctionCallOutputItem : InternalRealtimeResponseItem + internal partial class InternalRealtimeResponseFunctionCallOutputItem : InternalRealtimeConversationResponseItem { internal InternalRealtimeResponseFunctionCallOutputItem(string id, string callId, string output) : base(InternalRealtimeItemType.FunctionCallOutput, id) { @@ -15,7 +15,7 @@ internal InternalRealtimeResponseFunctionCallOutputItem(string id, string callId Output = output; } - internal InternalRealtimeResponseFunctionCallOutputItem(InternalRealtimeResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties, string callId, string output) : base(@object, @type, id, additionalBinaryDataProperties) + internal InternalRealtimeResponseFunctionCallOutputItem(InternalRealtimeConversationResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties, string callId, string output) : base(@object, @type, id, additionalBinaryDataProperties) { CallId = callId; Output = output; diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseItemObject.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseItemObject.cs deleted file mode 100644 index d5c5d6c55..000000000 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseItemObject.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.RealtimeConversation -{ - internal readonly partial struct InternalRealtimeResponseItemObject : IEquatable - { - private readonly string _value; - private const string RealtimeItemValue = "realtime.item"; - - public InternalRealtimeResponseItemObject(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static InternalRealtimeResponseItemObject RealtimeItem { get; } = new InternalRealtimeResponseItemObject(RealtimeItemValue); - - public static bool operator ==(InternalRealtimeResponseItemObject left, InternalRealtimeResponseItemObject right) => left.Equals(right); - - public static bool operator !=(InternalRealtimeResponseItemObject left, InternalRealtimeResponseItemObject right) => !left.Equals(right); - - public static implicit operator InternalRealtimeResponseItemObject(string value) => new InternalRealtimeResponseItemObject(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalRealtimeResponseItemObject other && Equals(other); - - public bool Equals(InternalRealtimeResponseItemObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseMessageItem.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseMessageItem.Serialization.cs index fc7df83e3..d0fa51478 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseMessageItem.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseMessageItem.Serialization.cs @@ -32,16 +32,6 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(InternalRealtimeResponseMessageItem)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); - if (true && _additionalBinaryDataProperties?.ContainsKey("content") != true) - { - writer.WritePropertyName("content"u8); - writer.WriteStartArray(); - foreach (ConversationContentPart item in Content) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } if (_additionalBinaryDataProperties?.ContainsKey("status") != true) { writer.WritePropertyName("status"u8); @@ -52,11 +42,21 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WritePropertyName("role"u8); writer.WriteStringValue(Role.ToString()); } + if (true && _additionalBinaryDataProperties?.ContainsKey("content") != true) + { + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (ConversationContentPart item in Content) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } } InternalRealtimeResponseMessageItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalRealtimeResponseMessageItem)JsonModelCreateCore(ref reader, options); - protected override InternalRealtimeResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected override InternalRealtimeConversationResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -73,18 +73,18 @@ internal static InternalRealtimeResponseMessageItem DeserializeInternalRealtimeR { return null; } - InternalRealtimeResponseItemObject @object = default; + InternalRealtimeConversationResponseItemObject @object = default; InternalRealtimeItemType @type = default; string id = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - IReadOnlyList content = default; ConversationItemStatus status = default; ConversationMessageRole role = default; + IReadOnlyList content = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("object"u8)) { - @object = new InternalRealtimeResponseItemObject(prop.Value.GetString()); + @object = new InternalRealtimeConversationResponseItemObject(prop.Value.GetString()); continue; } if (prop.NameEquals("type"u8)) @@ -102,16 +102,6 @@ internal static InternalRealtimeResponseMessageItem DeserializeInternalRealtimeR id = prop.Value.GetString(); continue; } - if (prop.NameEquals("content"u8)) - { - List array = new List(); - foreach (var item in prop.Value.EnumerateArray()) - { - array.Add(ConversationContentPart.DeserializeConversationContentPart(item, options)); - } - content = array; - continue; - } if (prop.NameEquals("status"u8)) { status = new ConversationItemStatus(prop.Value.GetString()); @@ -122,6 +112,16 @@ internal static InternalRealtimeResponseMessageItem DeserializeInternalRealtimeR role = new ConversationMessageRole(prop.Value.GetString()); continue; } + if (prop.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ConversationContentPart.DeserializeConversationContentPart(item, options)); + } + content = array; + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -132,9 +132,9 @@ internal static InternalRealtimeResponseMessageItem DeserializeInternalRealtimeR @type, id, additionalBinaryDataProperties, - content, status, - role); + role, + content); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); @@ -153,7 +153,7 @@ protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions InternalRealtimeResponseMessageItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalRealtimeResponseMessageItem)PersistableModelCreateCore(data, options); - protected override InternalRealtimeResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected override InternalRealtimeConversationResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseMessageItem.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseMessageItem.cs index 827580df0..87bf3c1ad 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseMessageItem.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseMessageItem.cs @@ -8,24 +8,22 @@ namespace OpenAI.RealtimeConversation { - internal partial class InternalRealtimeResponseMessageItem : InternalRealtimeResponseItem + internal partial class InternalRealtimeResponseMessageItem : InternalRealtimeConversationResponseItem { internal InternalRealtimeResponseMessageItem(string id, ConversationItemStatus status, ConversationMessageRole role) : base(InternalRealtimeItemType.Message, id) { - Content = new ChangeTrackingList(); Status = status; Role = role; + Content = new ChangeTrackingList(); } - internal InternalRealtimeResponseMessageItem(InternalRealtimeResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties, IReadOnlyList content, ConversationItemStatus status, ConversationMessageRole role) : base(@object, @type, id, additionalBinaryDataProperties) + internal InternalRealtimeResponseMessageItem(InternalRealtimeConversationResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties, ConversationItemStatus status, ConversationMessageRole role, IReadOnlyList content) : base(@object, @type, id, additionalBinaryDataProperties) { - Content = content; Status = status; Role = role; + Content = content; } - public IReadOnlyList Content { get; } - public ConversationItemStatus Status { get; } } } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreateResponse.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseOptions.Serialization.cs similarity index 68% rename from .dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreateResponse.Serialization.cs rename to .dotnet/src/Generated/Models/InternalRealtimeResponseOptions.Serialization.cs index e5feb25ba..7689a5e57 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreateResponse.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseOptions.Serialization.cs @@ -11,9 +11,9 @@ namespace OpenAI.RealtimeConversation { - internal partial class InternalRealtimeClientEventResponseCreateResponse : IJsonModel + internal partial class InternalRealtimeResponseOptions : IJsonModel { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -22,23 +22,18 @@ void IJsonModel.Write(Utf8Jso protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalRealtimeClientEventResponseCreateResponse)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeResponseOptions)} does not support writing '{format}' format."); } if (Optional.IsCollectionDefined(Modalities) && _additionalBinaryDataProperties?.ContainsKey("modalities") != true) { writer.WritePropertyName("modalities"u8); writer.WriteStartArray(); - foreach (string item in Modalities) + foreach (InternalRealtimeRequestSessionModality item in Modalities) { - if (item == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item); + writer.WriteStringValue(item.ToString()); } writer.WriteEndArray(); } @@ -50,12 +45,12 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(Voice) && _additionalBinaryDataProperties?.ContainsKey("voice") != true) { writer.WritePropertyName("voice"u8); - writer.WriteStringValue(Voice); + writer.WriteStringValue(Voice.Value.ToString()); } if (Optional.IsDefined(OutputAudioFormat) && _additionalBinaryDataProperties?.ContainsKey("output_audio_format") != true) { writer.WritePropertyName("output_audio_format"u8); - writer.WriteStringValue(OutputAudioFormat); + writer.WriteStringValue(OutputAudioFormat.Value.ToString()); } if (Optional.IsCollectionDefined(Tools) && _additionalBinaryDataProperties?.ContainsKey("tools") != true) { @@ -117,29 +112,29 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalRealtimeClientEventResponseCreateResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + InternalRealtimeResponseOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual InternalRealtimeClientEventResponseCreateResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual InternalRealtimeResponseOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalRealtimeClientEventResponseCreateResponse)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeResponseOptions)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRealtimeClientEventResponseCreateResponse(document.RootElement, options); + return DeserializeInternalRealtimeResponseOptions(document.RootElement, options); } - internal static InternalRealtimeClientEventResponseCreateResponse DeserializeInternalRealtimeClientEventResponseCreateResponse(JsonElement element, ModelReaderWriterOptions options) + internal static InternalRealtimeResponseOptions DeserializeInternalRealtimeResponseOptions(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - IList modalities = default; + IList modalities = default; string instructions = default; - string voice = default; - string outputAudioFormat = default; + ConversationVoice? voice = default; + ConversationAudioFormat? outputAudioFormat = default; IList tools = default; float? temperature = default; BinaryData maxOutputTokens = default; @@ -153,17 +148,10 @@ internal static InternalRealtimeClientEventResponseCreateResponse DeserializeInt { continue; } - List array = new List(); + List array = new List(); foreach (var item in prop.Value.EnumerateArray()) { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(item.GetString()); - } + array.Add(new InternalRealtimeRequestSessionModality(item.GetString())); } modalities = array; continue; @@ -175,12 +163,20 @@ internal static InternalRealtimeClientEventResponseCreateResponse DeserializeInt } if (prop.NameEquals("voice"u8)) { - voice = prop.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + voice = new ConversationVoice(prop.Value.GetString()); continue; } if (prop.NameEquals("output_audio_format"u8)) { - outputAudioFormat = prop.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outputAudioFormat = new ConversationAudioFormat(prop.Value.GetString()); continue; } if (prop.NameEquals("tools"u8)) @@ -229,8 +225,8 @@ internal static InternalRealtimeClientEventResponseCreateResponse DeserializeInt additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRealtimeClientEventResponseCreateResponse( - modalities ?? new ChangeTrackingList(), + return new InternalRealtimeResponseOptions( + modalities ?? new ChangeTrackingList(), instructions, voice, outputAudioFormat, @@ -241,53 +237,53 @@ internal static InternalRealtimeClientEventResponseCreateResponse DeserializeInt additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalRealtimeClientEventResponseCreateResponse)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeResponseOptions)} does not support writing '{options.Format}' format."); } } - InternalRealtimeClientEventResponseCreateResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + InternalRealtimeResponseOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual InternalRealtimeClientEventResponseCreateResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual InternalRealtimeResponseOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalRealtimeClientEventResponseCreateResponse(document.RootElement, options); + return DeserializeInternalRealtimeResponseOptions(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalRealtimeClientEventResponseCreateResponse)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeResponseOptions)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalRealtimeClientEventResponseCreateResponse internalRealtimeClientEventResponseCreateResponse) + public static implicit operator BinaryContent(InternalRealtimeResponseOptions internalRealtimeResponseOptions) { - if (internalRealtimeClientEventResponseCreateResponse == null) + if (internalRealtimeResponseOptions == null) { return null; } - return BinaryContent.Create(internalRealtimeClientEventResponseCreateResponse, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(internalRealtimeResponseOptions, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalRealtimeClientEventResponseCreateResponse(ClientResult result) + public static explicit operator InternalRealtimeResponseOptions(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalRealtimeClientEventResponseCreateResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeInternalRealtimeResponseOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreateResponse.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseOptions.cs similarity index 60% rename from .dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreateResponse.cs rename to .dotnet/src/Generated/Models/InternalRealtimeResponseOptions.cs index 652404768..9d27614fb 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreateResponse.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseOptions.cs @@ -8,17 +8,17 @@ namespace OpenAI.RealtimeConversation { - internal partial class InternalRealtimeClientEventResponseCreateResponse + internal partial class InternalRealtimeResponseOptions { private protected IDictionary _additionalBinaryDataProperties; - public InternalRealtimeClientEventResponseCreateResponse() + public InternalRealtimeResponseOptions() { - Modalities = new ChangeTrackingList(); + Modalities = new ChangeTrackingList(); Tools = new ChangeTrackingList(); } - internal InternalRealtimeClientEventResponseCreateResponse(IList modalities, string instructions, string voice, string outputAudioFormat, IList tools, float? temperature, BinaryData maxOutputTokens, BinaryData toolChoice, IDictionary additionalBinaryDataProperties) + internal InternalRealtimeResponseOptions(IList modalities, string instructions, ConversationVoice? voice, ConversationAudioFormat? outputAudioFormat, IList tools, float? temperature, BinaryData maxOutputTokens, BinaryData toolChoice, IDictionary additionalBinaryDataProperties) { Modalities = modalities; Instructions = instructions; @@ -31,13 +31,13 @@ internal InternalRealtimeClientEventResponseCreateResponse(IList modalit _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public IList Modalities { get; } + public IList Modalities { get; } public string Instructions { get; set; } - public string Voice { get; set; } + public ConversationVoice? Voice { get; set; } - public string OutputAudioFormat { get; set; } + public ConversationAudioFormat? OutputAudioFormat { get; set; } public IList Tools { get; } diff --git a/.dotnet/src/Generated/Models/InternalUnknownChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/InternalUnknownChatMessage.Serialization.cs index 1dbb31bef..70a0deb09 100644 --- a/.dotnet/src/Generated/Models/InternalUnknownChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalUnknownChatMessage.Serialization.cs @@ -45,19 +45,19 @@ internal static InternalUnknownChatMessage DeserializeInternalUnknownChatMessage { return null; } - Chat.ChatMessageRole role = default; ChatMessageContent content = default; + Chat.ChatMessageRole role = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("role"u8)) + if (prop.NameEquals("content"u8)) { - role = prop.Value.GetString().ToChatMessageRole(); + DeserializeContentValue(prop, ref content); continue; } - if (prop.NameEquals("content"u8)) + if (prop.NameEquals("role"u8)) { - DeserializeContentValue(prop, ref content); + role = prop.Value.GetString().ToChatMessageRole(); continue; } if (true) @@ -66,7 +66,7 @@ internal static InternalUnknownChatMessage DeserializeInternalUnknownChatMessage } } // CUSTOM: Initialize Content collection property. - return new InternalUnknownChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties); + return new InternalUnknownChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalUnknownChatMessage.cs b/.dotnet/src/Generated/Models/InternalUnknownChatMessage.cs index 994ab4d56..82bb59b2c 100644 --- a/.dotnet/src/Generated/Models/InternalUnknownChatMessage.cs +++ b/.dotnet/src/Generated/Models/InternalUnknownChatMessage.cs @@ -9,7 +9,7 @@ namespace OpenAI.Chat { internal partial class InternalUnknownChatMessage : ChatMessage { - internal InternalUnknownChatMessage(Chat.ChatMessageRole role, ChatMessageContent content, IDictionary additionalBinaryDataProperties) : base(role, content, additionalBinaryDataProperties) + internal InternalUnknownChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties) : base(content, role, additionalBinaryDataProperties) { } } diff --git a/.dotnet/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs b/.dotnet/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs index ccb709a79..db571acc7 100644 --- a/.dotnet/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs +++ b/.dotnet/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs @@ -80,8 +80,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsDefined(Usage) && _additionalBinaryDataProperties?.ContainsKey("usage") != true) { - writer.WritePropertyName("usage"u8); - writer.WriteObjectValue(Usage, options); + if (Usage != null) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + else + { + writer.WriteNull("usage"u8); + } } if (true && _additionalBinaryDataProperties != null) { @@ -183,6 +190,7 @@ internal static StreamingChatCompletionUpdate DeserializeStreamingChatCompletion { if (prop.Value.ValueKind == JsonValueKind.Null) { + usage = null; continue; } usage = ChatTokenUsage.DeserializeChatTokenUsage(prop.Value, options); diff --git a/.dotnet/src/Generated/Models/SystemChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/SystemChatMessage.Serialization.cs index 620f4d85d..9f11bed16 100644 --- a/.dotnet/src/Generated/Models/SystemChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/SystemChatMessage.Serialization.cs @@ -47,20 +47,20 @@ internal static SystemChatMessage DeserializeSystemChatMessage(JsonElement eleme { return null; } - Chat.ChatMessageRole role = default; ChatMessageContent content = default; + Chat.ChatMessageRole role = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string participantName = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("role"u8)) + if (prop.NameEquals("content"u8)) { - role = prop.Value.GetString().ToChatMessageRole(); + DeserializeContentValue(prop, ref content); continue; } - if (prop.NameEquals("content"u8)) + if (prop.NameEquals("role"u8)) { - DeserializeContentValue(prop, ref content); + role = prop.Value.GetString().ToChatMessageRole(); continue; } if (prop.NameEquals("name"u8)) @@ -74,7 +74,7 @@ internal static SystemChatMessage DeserializeSystemChatMessage(JsonElement eleme } } // CUSTOM: Initialize Content collection property. - return new SystemChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties, participantName); + return new SystemChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties, participantName); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/SystemChatMessage.cs b/.dotnet/src/Generated/Models/SystemChatMessage.cs index 0785ec94e..0f8453e0e 100644 --- a/.dotnet/src/Generated/Models/SystemChatMessage.cs +++ b/.dotnet/src/Generated/Models/SystemChatMessage.cs @@ -9,7 +9,7 @@ namespace OpenAI.Chat { public partial class SystemChatMessage : ChatMessage { - internal SystemChatMessage(Chat.ChatMessageRole role, ChatMessageContent content, IDictionary additionalBinaryDataProperties, string participantName) : base(role, content, additionalBinaryDataProperties) + internal SystemChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string participantName) : base(content, role, additionalBinaryDataProperties) { ParticipantName = participantName; } diff --git a/.dotnet/src/Generated/Models/ToolChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/ToolChatMessage.Serialization.cs index c3072ce6b..6762d530b 100644 --- a/.dotnet/src/Generated/Models/ToolChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/ToolChatMessage.Serialization.cs @@ -51,20 +51,20 @@ internal static ToolChatMessage DeserializeToolChatMessage(JsonElement element, { return null; } - Chat.ChatMessageRole role = default; ChatMessageContent content = default; + Chat.ChatMessageRole role = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string toolCallId = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("role"u8)) + if (prop.NameEquals("content"u8)) { - role = prop.Value.GetString().ToChatMessageRole(); + DeserializeContentValue(prop, ref content); continue; } - if (prop.NameEquals("content"u8)) + if (prop.NameEquals("role"u8)) { - DeserializeContentValue(prop, ref content); + role = prop.Value.GetString().ToChatMessageRole(); continue; } if (prop.NameEquals("tool_call_id"u8)) @@ -78,7 +78,7 @@ internal static ToolChatMessage DeserializeToolChatMessage(JsonElement element, } } // CUSTOM: Initialize Content collection property. - return new ToolChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties, toolCallId); + return new ToolChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties, toolCallId); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/ToolChatMessage.cs b/.dotnet/src/Generated/Models/ToolChatMessage.cs index 6e671b9c4..c0c786560 100644 --- a/.dotnet/src/Generated/Models/ToolChatMessage.cs +++ b/.dotnet/src/Generated/Models/ToolChatMessage.cs @@ -9,7 +9,7 @@ namespace OpenAI.Chat { public partial class ToolChatMessage : ChatMessage { - internal ToolChatMessage(Chat.ChatMessageRole role, ChatMessageContent content, IDictionary additionalBinaryDataProperties, string toolCallId) : base(role, content, additionalBinaryDataProperties) + internal ToolChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string toolCallId) : base(content, role, additionalBinaryDataProperties) { ToolCallId = toolCallId; } diff --git a/.dotnet/src/Generated/Models/UnknownRealtimeResponseItem.Serialization.cs b/.dotnet/src/Generated/Models/UnknownRealtimeResponseItem.Serialization.cs index f618f94fd..5a0d718b7 100644 --- a/.dotnet/src/Generated/Models/UnknownRealtimeResponseItem.Serialization.cs +++ b/.dotnet/src/Generated/Models/UnknownRealtimeResponseItem.Serialization.cs @@ -10,13 +10,13 @@ namespace OpenAI.RealtimeConversation { - internal partial class UnknownRealtimeResponseItem : IJsonModel + internal partial class UnknownRealtimeResponseItem : IJsonModel { internal UnknownRealtimeResponseItem() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -25,25 +25,25 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalRealtimeResponseItem)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeConversationResponseItem)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); } - InternalRealtimeResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + InternalRealtimeConversationResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected override InternalRealtimeResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected override InternalRealtimeConversationResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalRealtimeResponseItem)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeConversationResponseItem)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRealtimeResponseItem(document.RootElement, options); + return DeserializeInternalRealtimeConversationResponseItem(document.RootElement, options); } internal static UnknownRealtimeResponseItem DeserializeUnknownRealtimeResponseItem(JsonElement element, ModelReaderWriterOptions options) @@ -52,7 +52,7 @@ internal static UnknownRealtimeResponseItem DeserializeUnknownRealtimeResponseIt { return null; } - InternalRealtimeResponseItemObject @object = default; + InternalRealtimeConversationResponseItemObject @object = default; InternalRealtimeItemType @type = default; string id = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); @@ -60,7 +60,7 @@ internal static UnknownRealtimeResponseItem DeserializeUnknownRealtimeResponseIt { if (prop.NameEquals("object"u8)) { - @object = new InternalRealtimeResponseItemObject(prop.Value.GetString()); + @object = new InternalRealtimeConversationResponseItemObject(prop.Value.GetString()); continue; } if (prop.NameEquals("type"u8)) @@ -86,37 +86,37 @@ internal static UnknownRealtimeResponseItem DeserializeUnknownRealtimeResponseIt return new UnknownRealtimeResponseItem(@object, @type, id, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalRealtimeResponseItem)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeConversationResponseItem)} does not support writing '{options.Format}' format."); } } - InternalRealtimeResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + InternalRealtimeConversationResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected override InternalRealtimeResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected override InternalRealtimeConversationResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalRealtimeResponseItem(document.RootElement, options); + return DeserializeInternalRealtimeConversationResponseItem(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalRealtimeResponseItem)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalRealtimeConversationResponseItem)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/.dotnet/src/Generated/Models/UnknownRealtimeResponseItem.cs b/.dotnet/src/Generated/Models/UnknownRealtimeResponseItem.cs index bb08f7ea4..1f77d4c21 100644 --- a/.dotnet/src/Generated/Models/UnknownRealtimeResponseItem.cs +++ b/.dotnet/src/Generated/Models/UnknownRealtimeResponseItem.cs @@ -7,9 +7,9 @@ namespace OpenAI.RealtimeConversation { - internal partial class UnknownRealtimeResponseItem : InternalRealtimeResponseItem + internal partial class UnknownRealtimeResponseItem : InternalRealtimeConversationResponseItem { - internal UnknownRealtimeResponseItem(InternalRealtimeResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties) : base(@object, @type != default ? @type : "unknown", id, additionalBinaryDataProperties) + internal UnknownRealtimeResponseItem(InternalRealtimeConversationResponseItemObject @object, InternalRealtimeItemType @type, string id, IDictionary additionalBinaryDataProperties) : base(@object, @type != default ? @type : "unknown", id, additionalBinaryDataProperties) { } } diff --git a/.dotnet/src/Generated/Models/UserChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/UserChatMessage.Serialization.cs index 300edf218..c53bf0f9d 100644 --- a/.dotnet/src/Generated/Models/UserChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/UserChatMessage.Serialization.cs @@ -47,20 +47,20 @@ internal static UserChatMessage DeserializeUserChatMessage(JsonElement element, { return null; } - Chat.ChatMessageRole role = default; ChatMessageContent content = default; + Chat.ChatMessageRole role = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string participantName = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("role"u8)) + if (prop.NameEquals("content"u8)) { - role = prop.Value.GetString().ToChatMessageRole(); + DeserializeContentValue(prop, ref content); continue; } - if (prop.NameEquals("content"u8)) + if (prop.NameEquals("role"u8)) { - DeserializeContentValue(prop, ref content); + role = prop.Value.GetString().ToChatMessageRole(); continue; } if (prop.NameEquals("name"u8)) @@ -74,7 +74,7 @@ internal static UserChatMessage DeserializeUserChatMessage(JsonElement element, } } // CUSTOM: Initialize Content collection property. - return new UserChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties, participantName); + return new UserChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties, participantName); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/UserChatMessage.cs b/.dotnet/src/Generated/Models/UserChatMessage.cs index 259270b7f..4d7bda7a0 100644 --- a/.dotnet/src/Generated/Models/UserChatMessage.cs +++ b/.dotnet/src/Generated/Models/UserChatMessage.cs @@ -9,7 +9,7 @@ namespace OpenAI.Chat { public partial class UserChatMessage : ChatMessage { - internal UserChatMessage(Chat.ChatMessageRole role, ChatMessageContent content, IDictionary additionalBinaryDataProperties, string participantName) : base(role, content, additionalBinaryDataProperties) + internal UserChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string participantName) : base(content, role, additionalBinaryDataProperties) { ParticipantName = participantName; } diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index 10419b84a..77369458b 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -523,7 +523,7 @@ public static ConversationInputSpeechFinishedUpdate ConversationInputSpeechFinis return new ConversationInputSpeechFinishedUpdate(eventId, RealtimeConversation.ConversationUpdateKind.InputSpeechStopped, additionalBinaryDataProperties: null, itemId, audioEndMs); } - public static ConversationItemCreatedUpdate ConversationItemCreatedUpdate(string eventId = default, string previousItemId = default, InternalRealtimeResponseItem internalItem = default) + public static ConversationItemCreatedUpdate ConversationItemCreatedUpdate(string eventId = default, string previousItemId = default, InternalRealtimeConversationResponseItem internalItem = default) { return new ConversationItemCreatedUpdate(eventId, RealtimeConversation.ConversationUpdateKind.ItemCreated, additionalBinaryDataProperties: null, previousItemId, internalItem); @@ -613,7 +613,7 @@ public static ConversationResponseFinishedUpdate ConversationResponseFinishedUpd return new ConversationResponseFinishedUpdate(eventId, RealtimeConversation.ConversationUpdateKind.ResponseFinished, additionalBinaryDataProperties: null, internalResponse); } - public static ConversationItemStreamingStartedUpdate ConversationItemStreamingStartedUpdate(string eventId = default, string responseId = default, int itemIndex = default, InternalRealtimeResponseItem internalItem = default) + public static ConversationItemStreamingStartedUpdate ConversationItemStreamingStartedUpdate(string eventId = default, string responseId = default, int itemIndex = default, InternalRealtimeConversationResponseItem internalItem = default) { return new ConversationItemStreamingStartedUpdate( @@ -625,7 +625,7 @@ public static ConversationItemStreamingStartedUpdate ConversationItemStreamingSt internalItem); } - public static ConversationItemStreamingFinishedUpdate ConversationItemStreamingFinishedUpdate(string eventId = default, string responseId = default, int outputIndex = default, InternalRealtimeResponseItem internalItem = default) + public static ConversationItemStreamingFinishedUpdate ConversationItemStreamingFinishedUpdate(string eventId = default, string responseId = default, int outputIndex = default, InternalRealtimeConversationResponseItem internalItem = default) { return new ConversationItemStreamingFinishedUpdate( @@ -890,7 +890,7 @@ public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTok return new ChatInputTokenUsageDetails(audioTokenCount, cachedTokenCount, additionalBinaryDataProperties: null); } - public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalty = default, float? presencePenalty = default, ChatResponseFormat responseFormat = default, float? temperature = default, float? topP = default, IEnumerable tools = default, IEnumerable messages = default, InternalCreateChatCompletionRequestModel model = default, int? n = default, bool? stream = default, InternalChatCompletionStreamOptions streamOptions = default, bool? includeLogProbabilities = default, int? topLogProbabilityCount = default, IEnumerable stopSequences = default, IDictionary logitBiases = default, ChatToolChoice toolChoice = default, ChatFunctionChoice functionChoice = default, bool? allowParallelToolCalls = default, string endUserId = default, long? seed = default, int? deprecatedMaxTokens = default, int? maxOutputTokenCount = default, IEnumerable functions = default, IDictionary metadata = default, bool? storedOutputEnabled = default, InternalCreateChatCompletionRequestServiceTier? serviceTier = default) + public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalty = default, float? presencePenalty = default, ChatResponseFormat responseFormat = default, float? temperature = default, float? topP = default, IEnumerable tools = default, IEnumerable messages = default, InternalCreateChatCompletionRequestModel model = default, int? n = default, bool? stream = default, InternalChatCompletionStreamOptions streamOptions = default, bool? includeLogProbabilities = default, int? topLogProbabilityCount = default, IEnumerable stopSequences = default, IDictionary logitBiases = default, ChatToolChoice toolChoice = default, ChatFunctionChoice functionChoice = default, bool? allowParallelToolCalls = default, string endUserId = default, long? seed = default, int? deprecatedMaxTokens = default, int? maxOutputTokenCount = default, IEnumerable functions = default, IDictionary metadata = default, bool? storedOutputEnabled = default, InternalCreateChatCompletionRequestServiceTier? serviceTier = default, IEnumerable internalModalities = default, ChatAudioOptions audioOptions = default) { tools ??= new ChangeTrackingList(); messages ??= new ChangeTrackingList(); @@ -898,6 +898,7 @@ public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalt logitBiases ??= new ChangeTrackingDictionary(); functions ??= new ChangeTrackingList(); metadata ??= new ChangeTrackingDictionary(); + internalModalities ??= new ChangeTrackingList(); return new ChatCompletionOptions( frequencyPenalty, @@ -926,39 +927,42 @@ public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalt metadata, storedOutputEnabled, serviceTier, + internalModalities?.ToList(), + audioOptions, additionalBinaryDataProperties: null); } - public static ChatMessage ChatMessage(string role = default, ChatMessageContent content = default) + public static ChatMessage ChatMessage(ChatMessageContent content = default, string role = default) { - return new InternalUnknownChatMessage(role.ToChatMessageRole(), content, additionalBinaryDataProperties: null); + return new InternalUnknownChatMessage(content, role.ToChatMessageRole(), additionalBinaryDataProperties: null); } public static SystemChatMessage SystemChatMessage(ChatMessageContent content = default, string participantName = default) { - return new SystemChatMessage(Chat.ChatMessageRole.System, content, additionalBinaryDataProperties: null, participantName); + return new SystemChatMessage(content, Chat.ChatMessageRole.System, additionalBinaryDataProperties: null, participantName); } public static UserChatMessage UserChatMessage(ChatMessageContent content = default, string participantName = default) { - return new UserChatMessage(Chat.ChatMessageRole.User, content, additionalBinaryDataProperties: null, participantName); + return new UserChatMessage(content, Chat.ChatMessageRole.User, additionalBinaryDataProperties: null, participantName); } - public static AssistantChatMessage AssistantChatMessage(ChatMessageContent content = default, string refusal = default, string participantName = default, IEnumerable toolCalls = default, ChatFunctionCall functionCall = default) + public static AssistantChatMessage AssistantChatMessage(ChatMessageContent content = default, string refusal = default, string participantName = default, IEnumerable toolCalls = default, ChatFunctionCall functionCall = default, InternalChatCompletionRequestAssistantMessageAudio audio = default) { toolCalls ??= new ChangeTrackingList(); return new AssistantChatMessage( - Chat.ChatMessageRole.Assistant, content, + Chat.ChatMessageRole.Assistant, additionalBinaryDataProperties: null, refusal, participantName, toolCalls?.ToList(), - functionCall); + functionCall, + audio); } public static ChatToolCall ChatToolCall(string id = default, InternalChatCompletionMessageToolCallFunction function = default, Chat.ChatToolCallKind kind = default) @@ -976,13 +980,19 @@ public static ChatFunctionCall ChatFunctionCall(string functionName = default, B public static ToolChatMessage ToolChatMessage(ChatMessageContent content = default, string toolCallId = default) { - return new ToolChatMessage(Chat.ChatMessageRole.Tool, content, additionalBinaryDataProperties: null, toolCallId); + return new ToolChatMessage(content, Chat.ChatMessageRole.Tool, additionalBinaryDataProperties: null, toolCallId); } public static FunctionChatMessage FunctionChatMessage(ChatMessageContent content = default, string functionName = default) { - return new FunctionChatMessage(Chat.ChatMessageRole.Function, content, additionalBinaryDataProperties: null, functionName); + return new FunctionChatMessage(content, Chat.ChatMessageRole.Function, additionalBinaryDataProperties: null, functionName); + } + + public static ChatAudioOptions ChatAudioOptions(ChatResponseVoice responseVoice = default, ChatOutputAudioFormat outputAudioFormat = default) + { + + return new ChatAudioOptions(responseVoice, outputAudioFormat, additionalBinaryDataProperties: null); } public static ChatResponseFormat ChatResponseFormat(string @type = default) @@ -1225,10 +1235,19 @@ public static ChatMessageContent ChatMessageContent() return new ChatMessageContent(additionalBinaryDataProperties: null); } - public static ChatMessageContentPart ChatMessageContentPart(Chat.ChatMessageContentPartKind kind = default, string text = default, InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default, string refusal = default) + public static ChatMessageContentPart ChatMessageContentPart(Chat.ChatMessageContentPartKind kind = default, string text = default, InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default, string refusal = default, InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default, InternalChatCompletionResponseMessageAudio outputAudio = default, InternalChatCompletionMessageAudioChunk responseAudioUpdate = default, InternalChatCompletionRequestAssistantMessageAudio audioReference = default) { - return new ChatMessageContentPart(kind, text, imageUri, refusal, serializedAdditionalRawData: null); + return new ChatMessageContentPart( + kind, + text, + imageUri, + refusal, + inputAudio, + outputAudio, + responseAudioUpdate, + audioReference, + serializedAdditionalRawData: null); } public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionName = default, BinaryData functionArgumentsUpdate = default) diff --git a/.dotnet/tests/Chat/ChatSmokeTests.cs b/.dotnet/tests/Chat/ChatSmokeTests.cs index 9d1678080..618509ef2 100644 --- a/.dotnet/tests/Chat/ChatSmokeTests.cs +++ b/.dotnet/tests/Chat/ChatSmokeTests.cs @@ -533,6 +533,104 @@ public void SerializeRefusalMessages() Assert.That(serialized, Does.Not.Contain("content")); } + [Test] + public void SerializeAudioThings() + { + // User audio input: wire-correlated ("real") content parts should cleanly serialize/deserialize + ChatMessageContentPart inputAudioContentPart = ChatMessageContentPart.CreateAudioPart( + BinaryData.FromBytes([0x4, 0x2]), + ChatInputAudioFormat.Mp3); + Assert.That(inputAudioContentPart, Is.Not.Null); + BinaryData serializedInputAudioContentPart = ModelReaderWriter.Write(inputAudioContentPart); + Assert.That(serializedInputAudioContentPart.ToString(), Does.Contain(@"""format"":""mp3""")); + ChatMessageContentPart deserializedInputAudioContentPart = ModelReaderWriter.Read(serializedInputAudioContentPart); + Assert.That(deserializedInputAudioContentPart.AudioBytes.ToArray()[1], Is.EqualTo(0x2)); + + // Synthetic content parts wrapping input audio references should throw + ChatMessageContentPart audioReferenceContentPart = ChatMessageContentPart.CreateAudioPart("audio-id"); + Assert.Throws(() => ModelReaderWriter.Write(audioReferenceContentPart)); + + // That same synthetic content part should serialize to the right place when added to a message + AssistantChatMessage messageWithAudioReference = new([audioReferenceContentPart]); + BinaryData serializedMessageWithAudioReference = ModelReaderWriter.Write(messageWithAudioReference); + Assert.That(serializedMessageWithAudioReference.ToString(), Does.Contain(@"""audio"":{""id"":""audio-id""}")); + Assert.That(serializedMessageWithAudioReference.ToString(), Does.Not.Contain(@"""content""")); + + AssistantChatMessage message = ModelReaderWriter.Read(BinaryData.FromBytes(""" + { + "role": "assistant", + "audio": { + "id": "audio_correlated_id_1234" + } + } + """u8.ToArray())); + Assert.That(message.Content, Has.Count.EqualTo(1)); + Assert.That(message.Content[0].AudioCorrelationId, Is.EqualTo("audio_correlated_id_1234")); + string serializedMessage = ModelReaderWriter.Write(message).ToString(); + Assert.That(serializedMessage, Does.Contain(@"""audio"":{""id"":""audio_correlated_id_1234""}")); + + AssistantChatMessage ordinaryTextAssistantMessage = new(["This was a message from the assistant"]); + ordinaryTextAssistantMessage.Content.Add(ChatMessageContentPart.CreateAudioPart("extra-audio-id")); + BinaryData serializedLateAudioMessage = ModelReaderWriter.Write(ordinaryTextAssistantMessage); + Assert.That(serializedLateAudioMessage.ToString(), Does.Contain("was a message")); + Assert.That(serializedLateAudioMessage.ToString(), Does.Contain("extra-audio-id")); + + BinaryData rawAudioResponse = BinaryData.FromBytes(""" + { + "id": "chatcmpl-AOqyHuhjVDeGVbCZXJZ8mCLyl5nBq", + "object": "chat.completion", + "created": 1730486857, + "model": "gpt-4o-audio-preview-2024-10-01", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": null, + "refusal": null, + "audio": { + "id": "audio_6725224ac62481908ab55dc283289d87", + "data": "dHJ1bmNhdGVk", + "expires_at": 1730490458, + "transcript": "Hello there! How can I assist you with your test today?" + } + }, + "finish_reason": "stop" + } + ], + "usage": { + "prompt_tokens": 28, + "completion_tokens": 97, + "total_tokens": 125, + "prompt_tokens_details": { + "cached_tokens": 0, + "text_tokens": 11, + "image_tokens": 0, + "audio_tokens": 17 + }, + "completion_tokens_details": { + "reasoning_tokens": 0, + "text_tokens": 23, + "audio_tokens": 74, + "accepted_prediction_tokens": 0, + "rejected_prediction_tokens": 0 + } + }, + "system_fingerprint": "fp_49254d0e9b" + } + """u8.ToArray()); + ChatCompletion audioCompletion = ModelReaderWriter.Read(rawAudioResponse); + Assert.That(audioCompletion, Is.Not.Null); + + // Synthetic response audio content parts (reprojecting internal choices[*].message.audio) should throw when + // attempting independent serialization + Assert.Throws(() => ModelReaderWriter.Write(audioCompletion.Content[0])); + + AssistantChatMessage audioHistoryMessage = new(audioCompletion); + BinaryData serializedAudioHistoryMessage = ModelReaderWriter.Write(audioHistoryMessage); + Console.WriteLine(serializedAudioHistoryMessage.ToString()); + } + [Test] [TestCase(true)] [TestCase(false)] diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index b49439678..8c9ea8414 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -93,8 +93,6 @@ public void StreamingChat() latestTokenReceiptTime = stopwatch.Elapsed; usage ??= chatUpdate.Usage; updateCount++; - - Console.WriteLine(stopwatch.Elapsed.TotalMilliseconds); } stopwatch.Stop(); @@ -368,6 +366,71 @@ public async Task ChatWithVision() Assert.That(result.Value.Content[0].Text.ToLowerInvariant(), Does.Contain("dog").Or.Contain("cat").IgnoreCase); } + [Test] + public async Task ChatWithAudio() + { + ChatClient client = GetTestClient(TestScenario.Chat, "gpt-4o-audio-preview"); + + string helloWorldAudioPath = Path.Join("Assets", "audio_hello_world.mp3"); + BinaryData helloWorldAudioBytes = BinaryData.FromBytes(File.ReadAllBytes(helloWorldAudioPath)); + ChatMessageContentPart helloWorldAudioContentPart = ChatMessageContentPart.CreateAudioPart( + helloWorldAudioBytes, + ChatInputAudioFormat.Mp3); + string whatsTheWeatherAudioPath = Path.Join("Assets", "whats_the_weather_pcm16_24khz_mono.wav"); + BinaryData whatsTheWeatherAudioBytes = BinaryData.FromBytes(File.ReadAllBytes(whatsTheWeatherAudioPath)); + ChatMessageContentPart whatsTheWeatherAudioContentPart = ChatMessageContentPart.CreateAudioPart( + whatsTheWeatherAudioBytes, + ChatInputAudioFormat.Wav); + + List messages = [new UserChatMessage([helloWorldAudioContentPart])]; + + ChatCompletionOptions options = new() + { + AudioOptions = new(ChatResponseVoice.Alloy, ChatOutputAudioFormat.Pcm16) + }; + + ChatCompletion completion = await client.CompleteChatAsync(messages, options); + Assert.That(completion, Is.Not.Null); + Assert.That(completion.Content, Is.Not.Null); + Assert.That(completion.Content[0].Kind, Is.EqualTo(ChatMessageContentPartKind.Audio)); + Assert.That(completion.Content[0].AudioCorrelationId, Is.Not.Null.And.Not.Empty); + Assert.That(completion.Content[0].AudioBytes, Is.Not.Null); + Assert.That(completion.Content[0].AudioTranscript, Is.Not.Null.And.Not.Empty); + + AssistantChatMessage audioHistoryMessage = ChatMessage.CreateAssistantMessage(completion); + Assert.That(audioHistoryMessage, Is.InstanceOf()); + Assert.That(audioHistoryMessage.Content, Is.Not.Null.And.Not.Empty); + Assert.That(audioHistoryMessage.Content[0].Kind, Is.EqualTo(ChatMessageContentPartKind.Audio)); + Assert.That(audioHistoryMessage.Content[0].AudioCorrelationId, Is.EqualTo(completion.Content[0].AudioCorrelationId)); + Assert.That(audioHistoryMessage.Content[0].AudioBytes, Is.Null); + messages.Add(audioHistoryMessage); + + messages.Add( + new UserChatMessage( + [ + "Please answer the following spoken question:", + ChatMessageContentPart.CreateAudioPart(whatsTheWeatherAudioBytes, ChatInputAudioFormat.Wav), + ])); + + string streamedCorrelationId = null; + using MemoryStream responseAudioStream = new(); + await foreach (StreamingChatCompletionUpdate update in client.CompleteChatStreamingAsync(messages, options)) + { + Assert.That(update.ContentUpdate, Is.Not.Null); + if (update.ContentUpdate.Count > 0) + { + if (!string.IsNullOrEmpty(update.ContentUpdate[0].AudioCorrelationId)) + { + Assert.That(streamedCorrelationId, Is.Null.Or.EqualTo(update.ContentUpdate[0].AudioCorrelationId)); + streamedCorrelationId = update.ContentUpdate[0].AudioCorrelationId; + } + responseAudioStream.Write(update.ContentUpdate[0].AudioBytes); + } + } + Assert.That(streamedCorrelationId, Is.Not.Null.And.Not.Empty); + Assert.That(responseAudioStream.Length, Is.GreaterThan(9000)); + } + [Test] public async Task AuthFailure() { diff --git a/.dotnet/tests/Utility/TestHelpers.cs b/.dotnet/tests/Utility/TestHelpers.cs index a781a91a2..2bd540023 100644 --- a/.dotnet/tests/Utility/TestHelpers.cs +++ b/.dotnet/tests/Utility/TestHelpers.cs @@ -17,6 +17,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.RegularExpressions; [assembly: LevelOfParallelism(8)] @@ -49,7 +50,7 @@ public static T GetTestClient(TestScenario scenario, string overrideModel = n { options ??= new(); ApiKeyCredential credential = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); - options.AddPolicy(GetDumpPolicy(), PipelinePosition.PerTry); + options.AddPolicy(GetDumpPolicy(), PipelinePosition.BeforeTransport); object clientObject = scenario switch { #pragma warning disable OPENAI001 @@ -81,36 +82,48 @@ private static PipelinePolicy GetDumpPolicy() { return new TestPipelinePolicy((message) => { - Console.WriteLine($"--- New request ---"); - IEnumerable headerPairs = message?.Request?.Headers?.Select(header => $"{header.Key}={(header.Key.ToLower().Contains("auth") ? "***" : header.Value)}"); - string headers = string.Join(',', headerPairs); - Console.WriteLine($"Headers: {headers}"); - Console.WriteLine($"{message?.Request?.Method} URI: {message?.Request?.Uri}"); - if (message.Request?.Content != null) + if (message.Request is not null && message.Response is null) { - string contentType = "Unknown Content Type"; - if (message.Request.Headers?.TryGetValue("Content-Type", out contentType) == true - && contentType == "application/json") + Console.WriteLine($"--- New request ---"); + IEnumerable headerPairs = message?.Request?.Headers?.Select(header => $"{header.Key}={(header.Key.ToLower().Contains("auth") ? "***" : header.Value)}"); + string headers = string.Join(',', headerPairs); + Console.WriteLine($"Headers: {headers}"); + Console.WriteLine($"{message?.Request?.Method} URI: {message?.Request?.Uri}"); + if (message.Request?.Content != null) { - using MemoryStream stream = new(); - message.Request.Content.WriteTo(stream, default); - stream.Position = 0; - using StreamReader reader = new(stream); - Console.WriteLine(reader.ReadToEnd()); - } - else - { - string length = message.Request.Content.TryComputeLength(out long numberLength) - ? $"{numberLength} bytes" - : "unknown length"; - Console.WriteLine($"<< Non-JSON content: {contentType} >> {length}"); + string contentType = "Unknown Content Type"; + if (message.Request.Headers?.TryGetValue("Content-Type", out contentType) == true + && contentType == "application/json") + { + using MemoryStream stream = new(); + message.Request.Content.WriteTo(stream, default); + stream.Position = 0; + using StreamReader reader = new(stream); + string requestDump = reader.ReadToEnd(); + requestDump = Regex.Replace(requestDump, @"""data"":[\\w\\r\\n]*""[^""]*""", @"""data"":""..."""); + Console.WriteLine(requestDump); + } + else + { + string length = message.Request.Content.TryComputeLength(out long numberLength) + ? $"{numberLength} bytes" + : "unknown length"; + Console.WriteLine($"<< Non-JSON content: {contentType} >> {length}"); + } } } if (message.Response != null) { - Console.WriteLine("--- Begin response content ---"); - Console.WriteLine(message.Response.Content?.ToString()); - Console.WriteLine("--- End of response content ---"); + if (message.BufferResponse) + { + Console.WriteLine("--- Begin response content ---"); + Console.WriteLine(message.Response.Content?.ToString()); + Console.WriteLine("--- End of response content ---"); + } + else + { + Console.WriteLine("--- Response (unbuffered, content not rendered) ---"); + } } }); } diff --git a/.dotnet/tests/Utility/TestPipelinePolicy.cs b/.dotnet/tests/Utility/TestPipelinePolicy.cs index 688c407ed..c596295f4 100644 --- a/.dotnet/tests/Utility/TestPipelinePolicy.cs +++ b/.dotnet/tests/Utility/TestPipelinePolicy.cs @@ -17,19 +17,15 @@ public TestPipelinePolicy(Action processMessageAction) public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) { - _processMessageAction(message); - if (currentIndex < pipeline.Count - 1) - { - pipeline[currentIndex + 1].Process(message, pipeline, currentIndex + 1); - } + _processMessageAction(message); // for request + ProcessNext(message, pipeline, currentIndex); + _processMessageAction(message); // for response } public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) { - _processMessageAction(message); - if (currentIndex < pipeline.Count - 1) - { - await pipeline[currentIndex + 1].ProcessAsync(message, pipeline, currentIndex + 1); - } + _processMessageAction(message); // for request + await ProcessNextAsync(message, pipeline, currentIndex); + _processMessageAction(message); // for response } } \ No newline at end of file diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index faf6a1a53..2f373d995 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -3820,6 +3820,19 @@ components: parameters: $ref: '#/components/schemas/FunctionParameters' deprecated: true + ChatCompletionMessageAudioChunk: + type: object + properties: + id: + type: string + transcript: + type: string + data: + type: string + format: base64 + expires_at: + type: integer + format: unixtime ChatCompletionMessageToolCall: type: object required: @@ -3878,6 +3891,24 @@ components: items: $ref: '#/components/schemas/ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. + ChatCompletionModalities: + type: array + items: + type: string + enum: + - text + - audio + description: |- + Output types that you would like the model to generate for this request. + Most models are capable of generating text, which is the default: + + `["text"]` + + The `gpt-4o-audio-preview` model can also be used to [generate audio](/docs/guides/audio). To + request that this model generate both text and audio responses, you can + use: + + `["text", "audio"]` ChatCompletionNamedToolChoice: type: object required: @@ -3924,6 +3955,19 @@ components: name: type: string description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + audio: + type: object + properties: + id: + type: string + description: Unique identifier for a previous audio response from the model. + required: + - id + nullable: true + description: |- + Data about a previous audio response from the model. + [Learn more](/docs/guides/audio). + x-oaiExpandable: true tool_calls: $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: @@ -3985,6 +4029,34 @@ components: tool: '#/components/schemas/ChatCompletionRequestToolMessage' function: '#/components/schemas/ChatCompletionRequestFunctionMessage' x-oaiExpandable: true + ChatCompletionRequestMessageContentPartAudio: + type: object + required: + - type + - input_audio + properties: + type: + type: string + enum: + - input_audio + description: The type of the content part. Always `input_audio`. + input_audio: + type: object + properties: + data: + type: string + format: base64 + description: Base64 encoded audio data. + format: + type: string + enum: + - wav + - mp3 + description: The format of the encoded audio data. Currently supports "wav" and "mp3". + required: + - data + - format + description: Learn about [audio inputs](/docs/guides/audio). ChatCompletionRequestMessageContentPartImage: type: object required: @@ -4013,6 +4085,7 @@ components: default: auto required: - url + description: Learn about [image inputs](/docs/guides/vision). ChatCompletionRequestMessageContentPartRefusal: type: object required: @@ -4041,6 +4114,7 @@ components: text: type: string description: The text content. + description: Learn about [text inputs](/docs/guides/text-generation). ChatCompletionRequestSystemMessage: type: object required: @@ -4126,6 +4200,7 @@ components: anyOf: - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartImage' + - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartAudio' x-oaiExpandable: true ChatCompletionResponseMessage: type: object @@ -4162,6 +4237,38 @@ components: - arguments description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true + audio: + type: object + properties: + id: + type: string + description: Unique identifier for this audio response. + expires_at: + type: integer + format: unixtime + description: |- + The Unix timestamp (in seconds) for when this audio response will + no longer be accessible on the server for use in multi-turn + conversations. + data: + type: string + format: base64 + description: |- + Base64 encoded audio bytes generated by the model, in the format + specified in the request. + transcript: + type: string + description: Transcript of the audio generated by the model. + required: + - id + - expires_at + - data + - transcript + nullable: true + description: |- + If the audio output modality is requested, this object contains data + about the audio response from the model. [Learn more](/docs/guides/audio). + x-oaiExpandable: true description: A chat completion message generated by the model. ChatCompletionRole: type: string @@ -4182,6 +4289,10 @@ components: ChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. content: type: string nullable: true @@ -4609,7 +4720,11 @@ components: items: $ref: '#/components/schemas/ChatCompletionRequestMessage' minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + description: |- + A list of messages comprising the conversation so far. Depending on the + [model](/docs/models) you use, different message types (modalities) are + supported, like [text](/docs/guides/text-generation), + [images](/docs/guides/vision), and [audio](/docs/guides/audio). model: anyOf: - type: string @@ -4624,6 +4739,8 @@ components: - gpt-4o-2024-05-13 - gpt-4o-realtime-preview - gpt-4o-realtime-preview-2024-10-01 + - gpt-4o-audio-preview + - gpt-4o-audio-preview-2024-10-01 - chatgpt-4o-latest - gpt-4o-mini - gpt-4o-mini-2024-07-18 @@ -4720,6 +4837,45 @@ components: maximum: 128 description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. default: 1 + modalities: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionModalities' + nullable: true + audio: + type: object + properties: + voice: + type: string + enum: + - alloy + - echo + - fable + - onyx + - nova + - shimmer + description: |- + Specifies the voice type. Supported voices are `alloy`, `echo`, + `fable`, `onyx`, `nova`, and `shimmer`. + format: + type: string + enum: + - wav + - mp3 + - flac + - opus + - pcm16 + description: |- + Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, + `opus`, or `pcm16`. + required: + - voice + - format + nullable: true + description: |- + Parameters for audio output. Required when audio output is requested with + `modalities: ["audio"]`. [Learn more](/docs/guides/audio). + x-oaiExpandable: true presence_penalty: type: number format: float @@ -5053,6 +5209,7 @@ components: - completion_tokens - prompt_tokens - total_tokens + nullable: true description: |- An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request. When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request. @@ -9061,17 +9218,17 @@ components: type: string enum: - conversation.item.create - description: The event type, must be "conversation.item.create". + description: The event type, must be `conversation.item.create`. previous_item_id: type: string - description: The ID of the preceding item after which the new item will be inserted. + description: The ID of the preceding item after which the new item will be inserted. If not set, the new item will be appended to the end of the conversation. If set, it allows an item to be inserted mid-conversation. If the ID cannot be found, an error will be returned and the item will not be added. item: - allOf: - - $ref: '#/components/schemas/RealtimeRequestItem' - description: The item to add to the conversation. + $ref: '#/components/schemas/RealtimeConversationRequestItem' allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event when adding an item to the conversation. + description: |- + Add a new Item to the Conversation's context, including messages, function calls, and function call responses. This event can be used both to populate a "history" of the conversation and to add new items mid-stream, but has the current limitation that it cannot populate assistant audio messages. + If successful, the server will respond with a `conversation.item.created` event, otherwise an `error` event will be sent. RealtimeClientEventConversationItemDelete: type: object required: @@ -9088,7 +9245,7 @@ components: description: The ID of the item to delete. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event when you want to remove any item from the conversation history. + description: Send this event when you want to remove any item from the conversation history. The server will respond with a `conversation.item.deleted` event, unless the item does not exist in the conversation history, in which case the server will respond with an error. RealtimeClientEventConversationItemTruncate: type: object required: @@ -9104,18 +9261,21 @@ components: description: The event type, must be "conversation.item.truncate". item_id: type: string - description: The ID of the assistant message item to truncate. + description: The ID of the assistant message item to truncate. Only assistant message items can be truncated. content_index: type: integer format: int32 - description: The index of the content part to truncate. + description: The index of the content part to truncate. Set this to 0. audio_end_ms: type: integer format: int32 - description: Inclusive duration up to which audio is truncated, in milliseconds. + description: Inclusive duration up to which audio is truncated, in milliseconds. If the audio_end_ms is greater than the actual audio duration, the server will respond with an error. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event when you want to truncate a previous assistant message’s audio. + description: |- + Send this event to truncate a previous assistant message’s audio. The server will produce audio faster than realtime, so this event is useful when the user interrupts to truncate audio that has already been sent to the client but not yet played. This will synchronize the server's understanding of the audio with the client's playback. + Truncating audio will delete the server-side text transcript to ensure there is not text in the context that hasn't been heard by the user. + If successful, the server will respond with a `conversation.item.truncated` event. RealtimeClientEventInputAudioBufferAppend: type: object required: @@ -9130,10 +9290,12 @@ components: audio: type: string format: base64 - description: Base64-encoded audio bytes. + description: Base64-encoded audio bytes. This must be in the format specified by the `input_audio_format` field in the session configuration. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event to append audio bytes to the input audio buffer. + description: |- + Send this event to append audio bytes to the input audio buffer. The audio buffer is temporary storage you can write to and later commit. In Server VAD mode, the audio buffer is used to detect speech and the server will decide when to commit. When Server VAD is disabled, you must commit the audio buffer manually. + The client may choose how much audio to place in each event up to a maximum of 15 MiB, for example streaming smaller chunks from the client may allow the VAD to be more responsive. Unlike made other client events, the server will not send a confirmation response to this event. RealtimeClientEventInputAudioBufferClear: type: object required: @@ -9146,7 +9308,7 @@ components: description: The event type, must be "input_audio_buffer.clear". allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event to clear the audio bytes in the buffer. + description: Send this event to clear the audio bytes in the buffer. The server will respond with an `input_audio_buffer.cleared` event. RealtimeClientEventInputAudioBufferCommit: type: object required: @@ -9159,7 +9321,9 @@ components: description: The event type, must be "input_audio_buffer.commit". allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event to commit audio bytes to a user message. + description: |- + Send this event to commit the user input audio buffer, which will create a new user message item in the conversation. This event will produce an error if the input audio buffer is empty. When in Server VAD mode, the client does not need to send this event, the server will commit the audio buffer automatically. + Committing the input audio buffer will trigger input audio transcription (if enabled in session configuration), but it will not create a response from the model. The server will respond with an `input_audio_buffer.committed` event. RealtimeClientEventResponseCancel: type: object required: @@ -9169,10 +9333,10 @@ components: type: string enum: - response.cancel - description: The event type, must be "response.cancel". + description: The event type, must be `response.cancel`. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event to cancel an in-progress response. + description: Send this event to cancel an in-progress response. The server will respond with a `response.cancelled` event or an error if there is no response to cancel. RealtimeClientEventResponseCreate: type: object required: @@ -9183,48 +9347,16 @@ components: type: string enum: - response.create - description: The event type, must be "response.create". + description: The event type, must be `response.create`. response: - type: object - properties: - modalities: - type: array - items: - type: string - description: The modalities for the response. - instructions: - type: string - description: Instructions for the model. - voice: - type: string - description: The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. - output_audio_format: - type: string - description: The format of output audio. - tools: - type: array - items: - $ref: '#/components/schemas/RealtimeTool' - description: Tools (functions) available to the model. - tool_choice: - type: string - description: How the model chooses tools. - temperature: - type: number - format: float - description: Sampling temperature. - max_output_tokens: - anyOf: - - type: integer - format: int32 - - type: string - enum: - - inf - description: Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf". - description: Configuration for the response. + $ref: '#/components/schemas/RealtimeResponseOptions' allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event to trigger a response generation. + description: |- + This event instructs the server to create a Response, which means triggering model inference. When in Server VAD mode, the server will create Responses automatically. + A Response will include at least one Item, and may have two, in which case the second will be a function call. These Items will be appended to the conversation history. + The server will respond with a `response.created` event, events for Items and content created, and finally a `response.done` event to indicate the Response is complete. + The `response.create` event includes inference configuration like `instructions`, and `temperature`. These fields will override the Session's configuration for this Response only. RealtimeClientEventSessionUpdate: type: object required: @@ -9237,12 +9369,10 @@ components: - session.update description: The event type, must be "session.update". session: - allOf: - - $ref: '#/components/schemas/RealtimeRequestSession' - description: Session configuration to update. + $ref: '#/components/schemas/RealtimeRequestSession' allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event to update the session’s default configuration. + description: Send this event to update the session’s default configuration. The client may send this event at any time to update the session configuration, and any field may be updated at any time, except for "voice". The server will respond with a `session.updated` event that shows the full effective configuration. Only fields that are present are updated, thus the correct way to clear a field like "instructions" is to pass an empty string. RealtimeClientEventType: anyOf: - type: string @@ -9280,6 +9410,46 @@ components: - input_audio - text - audio + RealtimeConversationItemBase: + type: object + description: The item to add to the conversation. + RealtimeConversationRequestItem: + type: object + required: + - type + properties: + type: + $ref: '#/components/schemas/RealtimeItemType' + id: + type: string + discriminator: + propertyName: type + mapping: + message: '#/components/schemas/RealtimeRequestMessageItem' + function_call: '#/components/schemas/RealtimeRequestFunctionCallItem' + function_call_output: '#/components/schemas/RealtimeRequestFunctionCallOutputItem' + RealtimeConversationResponseItem: + type: object + required: + - object + - type + - id + properties: + object: + type: string + enum: + - realtime.item + type: + $ref: '#/components/schemas/RealtimeItemType' + id: + type: string + nullable: true + discriminator: + propertyName: type + mapping: + message: '#/components/schemas/RealtimeResponseMessageItem' + function_call: '#/components/schemas/RealtimeResponseFunctionCallItem' + function_call_output: '#/components/schemas/RealtimeResponseFunctionCallOutputItem' RealtimeFunctionTool: type: object required: @@ -9372,7 +9542,7 @@ components: status: $ref: '#/components/schemas/RealtimeItemStatus' allOf: - - $ref: '#/components/schemas/RealtimeRequestItem' + - $ref: '#/components/schemas/RealtimeConversationRequestItem' RealtimeRequestFunctionCallOutputItem: type: object required: @@ -9389,22 +9559,7 @@ components: output: type: string allOf: - - $ref: '#/components/schemas/RealtimeRequestItem' - RealtimeRequestItem: - type: object - required: - - type - properties: - type: - $ref: '#/components/schemas/RealtimeItemType' - id: - type: string - discriminator: - propertyName: type - mapping: - message: '#/components/schemas/RealtimeRequestMessageItem' - function_call: '#/components/schemas/RealtimeRequestFunctionCallItem' - function_call_output: '#/components/schemas/RealtimeRequestFunctionCallOutputItem' + - $ref: '#/components/schemas/RealtimeConversationRequestItem' RealtimeRequestMessageItem: type: object required: @@ -9426,7 +9581,7 @@ components: user: '#/components/schemas/RealtimeRequestUserMessageItem' assistant: '#/components/schemas/RealtimeRequestAssistantMessageItem' allOf: - - $ref: '#/components/schemas/RealtimeRequestItem' + - $ref: '#/components/schemas/RealtimeConversationRequestItem' RealtimeRequestMessageReferenceItem: type: object required: @@ -9559,7 +9714,7 @@ components: output: type: array items: - $ref: '#/components/schemas/RealtimeResponseItem' + $ref: '#/components/schemas/RealtimeConversationResponseItem' usage: type: object properties: @@ -9621,6 +9776,9 @@ components: nullable: true allOf: - $ref: '#/components/schemas/RealtimeContentPart' + RealtimeResponseBase: + type: object + description: The response resource. RealtimeResponseFunctionCallItem: type: object required: @@ -9643,7 +9801,7 @@ components: status: $ref: '#/components/schemas/RealtimeItemStatus' allOf: - - $ref: '#/components/schemas/RealtimeResponseItem' + - $ref: '#/components/schemas/RealtimeConversationResponseItem' RealtimeResponseFunctionCallOutputItem: type: object required: @@ -9660,29 +9818,7 @@ components: output: type: string allOf: - - $ref: '#/components/schemas/RealtimeResponseItem' - RealtimeResponseItem: - type: object - required: - - object - - type - - id - properties: - object: - type: string - enum: - - realtime.item - type: - $ref: '#/components/schemas/RealtimeItemType' - id: - type: string - nullable: true - discriminator: - propertyName: type - mapping: - message: '#/components/schemas/RealtimeResponseMessageItem' - function_call: '#/components/schemas/RealtimeResponseFunctionCallItem' - function_call_output: '#/components/schemas/RealtimeResponseFunctionCallOutputItem' + - $ref: '#/components/schemas/RealtimeConversationResponseItem' RealtimeResponseMessageItem: type: object required: @@ -9705,7 +9841,50 @@ components: status: $ref: '#/components/schemas/RealtimeItemStatus' allOf: - - $ref: '#/components/schemas/RealtimeResponseItem' + - $ref: '#/components/schemas/RealtimeConversationResponseItem' + RealtimeResponseOptions: + type: object + properties: + modalities: + type: array + items: + type: string + enum: + - text + - audio + description: The modalities for the response. + instructions: + type: string + description: Instructions for the model. + voice: + allOf: + - $ref: '#/components/schemas/RealtimeVoice' + description: The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. + output_audio_format: + allOf: + - $ref: '#/components/schemas/RealtimeAudioFormat' + description: The format of output audio. + tools: + type: array + items: + $ref: '#/components/schemas/RealtimeTool' + description: Tools (functions) available to the model. + tool_choice: + allOf: + - $ref: '#/components/schemas/RealtimeToolChoice' + description: How the model chooses tools. + temperature: + type: number + format: float + description: Sampling temperature. + max_output_tokens: + anyOf: + - type: integer + format: int32 + - type: string + enum: + - inf + description: Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf". RealtimeResponseSession: type: object required: @@ -9881,17 +10060,19 @@ components: type: string enum: - conversation.item.created - description: The event type, must be "conversation.item.created". + description: The event type, must be `conversation.item.created`. previous_item_id: type: string - description: The ID of the preceding item. + description: The ID of the preceding item in the Conversation context, allows the client to understand the order of the conversation. item: - allOf: - - $ref: '#/components/schemas/RealtimeResponseItem' - description: The item that was created. + $ref: '#/components/schemas/RealtimeConversationResponseItem' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a conversation item is created. + description: |- + Returned when a conversation item is created. There are several scenarios that produce this event: + - The server is generating a Response, which if successful will produce either one or two Items, which will be of type `message` (role `assistant`) or type `function_call`. + - The input audio buffer has been committed, either by the client or the server (in `server_vad` mode). The server will take the content of the input audio buffer and add it to a new user message Item. + - The client has sent a `conversation.item.create` event to add a new Item to the Conversation. RealtimeServerEventConversationItemDeleted: type: object required: @@ -9902,13 +10083,13 @@ components: type: string enum: - conversation.item.deleted - description: The event type, must be "conversation.item.deleted". + description: The event type, must be `conversation.item.deleted`. item_id: type: string description: The ID of the item that was deleted. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when an item in the conversation is deleted. + description: Returned when an item in the conversation is deleted by the client with a `conversation.item.delete` event. This event is used to synchronize the server's understanding of the conversation history with the client's view. RealtimeServerEventConversationItemInputAudioTranscriptionCompleted: type: object required: @@ -9921,10 +10102,10 @@ components: type: string enum: - conversation.item.input_audio_transcription.completed - description: The event type, must be "conversation.item.input_audio_transcription.completed". + description: The event type, must be `conversation.item.input_audio_transcription.completed`. item_id: type: string - description: The ID of the user message item. + description: The ID of the user message item containing the audio. content_index: type: integer format: int32 @@ -9934,7 +10115,9 @@ components: description: The transcribed text. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when input audio transcription is enabled and a transcription succeeds. + description: |- + This event is the output of audio transcription for user audio written to the user audio buffer. Transcription begins when the input audio buffer is committed by the client or server (in `server_vad` mode). Transcription runs asynchronously with Response creation, so this event may come before or after the Response events. + Realtime API models accept audio natively, and thus input transcription is a separate process run on a separate ASR (Automatic Speech Recognition) model, currently always `whisper-1`. Thus the transcript may diverge somewhat from the model's interpretation, and should be treated as a rough guide. RealtimeServerEventConversationItemInputAudioTranscriptionFailed: type: object required: @@ -9947,7 +10130,7 @@ components: type: string enum: - conversation.item.input_audio_transcription.failed - description: The event type, must be "conversation.item.input_audio_transcription.failed". + description: The event type, must be `conversation.item.input_audio_transcription.failed`. item_id: type: string description: The ID of the user message item. @@ -9973,7 +10156,7 @@ components: description: Details of the transcription error. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when input audio transcription is configured, and a transcription request for a user message failed. + description: Returned when input audio transcription is configured, and a transcription request for a user message failed. These events are separate from other `error` events so that the client can identify the related Item. RealtimeServerEventConversationItemTruncated: type: object required: @@ -9986,7 +10169,7 @@ components: type: string enum: - conversation.item.truncated - description: The event type, must be "conversation.item.truncated". + description: The event type, must be `conversation.item.truncated`. item_id: type: string description: The ID of the assistant message item that was truncated. @@ -10000,7 +10183,9 @@ components: description: The duration up to which the audio was truncated, in milliseconds. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when an earlier assistant audio message item is truncated by the client. + description: |- + Returned when an earlier assistant audio message item is truncated by the client with a `conversation.item.truncate` event. This event is used to synchronize the server's understanding of the audio with the client's playback. + This action will truncate the audio and remove the server-side text transcript to ensure there is no text in the context that hasn't been heard by the user. RealtimeServerEventError: type: object required: @@ -10033,7 +10218,7 @@ components: description: Details of the error. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when an error occurs. + description: Returned when an error occurs, which could be a client problem or a server problem. Most errors are recoverable and the session will stay open, we recommend to implementors to monitor and log error messages by default. RealtimeServerEventInputAudioBufferCleared: type: object required: @@ -10043,10 +10228,10 @@ components: type: string enum: - input_audio_buffer.cleared - description: The event type, must be "input_audio_buffer.cleared". + description: The event type, must be `input_audio_buffer.cleared`. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when the input audio buffer is cleared by the client. + description: Returned when the input audio buffer is cleared by the client with a `input_audio_buffer.clear` event. RealtimeServerEventInputAudioBufferCommitted: type: object required: @@ -10058,7 +10243,7 @@ components: type: string enum: - input_audio_buffer.committed - description: The event type, must be "input_audio_buffer.committed". + description: The event type, must be `input_audio_buffer.committed`. previous_item_id: type: string description: The ID of the preceding item after which the new item will be inserted. @@ -10067,7 +10252,7 @@ components: description: The ID of the user message item that will be created. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. + description: Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. The `item_id` property is the ID of the user message item that will be created, thus a `conversation.item.created` event will also be sent to the client. RealtimeServerEventInputAudioBufferSpeechStarted: type: object required: @@ -10079,17 +10264,17 @@ components: type: string enum: - input_audio_buffer.speech_started - description: The event type, must be "input_audio_buffer.speech_started". + description: The event type, must be `input_audio_buffer.speech_started`. audio_start_ms: type: integer format: int32 - description: Milliseconds since the session started when speech was detected. + description: Milliseconds from the start of all audio written to the buffer during the session when speech was first detected. This will correspond to the beginning of audio sent to the model, and thus includes the `prefix_padding_ms` configured in the Session. item_id: type: string description: The ID of the user message item that will be created when speech stops. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned in server turn detection mode when speech is detected. + description: Sent by the server when in `server_vad` mode to indicate that speech has been detected in the audio buffer. This can happen any time audio is added to the buffer (unless speech is already detected). The client may want to use this event to interrupt audio playback or provide visual feedback to the user. The client should expect to receive a `input_audio_buffer.speech_stopped` event when speech stops. The `item_id` property is the ID of the user message item that will be created when speech stops and will also be included in the `input_audio_buffer.speech_stopped` event (unless the client manually commits the audio buffer during VAD activation). RealtimeServerEventInputAudioBufferSpeechStopped: type: object required: @@ -10101,17 +10286,17 @@ components: type: string enum: - input_audio_buffer.speech_stopped - description: The event type, must be "input_audio_buffer.speech_stopped". + description: The event type, must be `input_audio_buffer.speech_stopped`. audio_end_ms: type: integer format: int32 - description: Milliseconds since the session started when speech stopped. + description: Milliseconds since the session started when speech stopped. This will correspond to the end of audio sent to the model, and thus includes the `min_silence_duration_ms` configured in the Session. item_id: type: string description: The ID of the user message item that will be created. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned in server turn detection mode when speech stops. + description: Returned in `server_vad` mode when the server detects the end of speech in the audio buffer. The server will also send an `conversation.item.created` event with the user message item that is created from the audio buffer. RealtimeServerEventRateLimitsUpdated: type: object required: @@ -10122,7 +10307,7 @@ components: type: string enum: - rate_limits.updated - description: The event type, must be "rate_limits.updated". + description: The event type, must be `rate_limits.updated`. rate_limits: type: array items: @@ -10130,7 +10315,7 @@ components: description: List of rate limit information. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Emitted after every "response.done" event to indicate the updated rate limits. + description: Emitted at the beginning of a Response to indicate the updated rate limits. When a Response is created some tokens will be "reserved" for the output tokens, the rate limits shown here reflect that reservation, which is then adjusted accordingly once the Response is completed. RealtimeServerEventRateLimitsUpdatedRateLimitsItem: type: object required: @@ -10373,14 +10558,12 @@ components: type: string enum: - response.created - description: The event type, must be "response.created". + description: The event type, must be `response.created`. response: - allOf: - - $ref: '#/components/schemas/RealtimeResponse' - description: The response resource. + $ref: '#/components/schemas/RealtimeResponse' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a new Response is created. The first event of response creation, where the response is in an initial state of "in_progress". + description: Returned when a new Response is created. The first event of response creation, where the response is in an initial state of `in_progress`. RealtimeServerEventResponseDone: type: object required: @@ -10393,12 +10576,10 @@ components: - response.done description: The event type, must be "response.done". response: - allOf: - - $ref: '#/components/schemas/RealtimeResponse' - description: The response resource. + $ref: '#/components/schemas/RealtimeResponse' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a Response is done streaming. Always emitted, no matter the final state. + description: Returned when a Response is done streaming. Always emitted, no matter the final state. The Response object included in the `response.done` event will include all output Items in the Response but will omit the raw audio data. RealtimeServerEventResponseFunctionCallArgumentsDelta: type: object required: @@ -10479,21 +10660,19 @@ components: type: string enum: - response.output_item.added - description: The event type, must be "response.output_item.added". + description: The event type, must be `response.output_item.added`. response_id: type: string - description: The ID of the response to which the item belongs. + description: The ID of the Response to which the item belongs. output_index: type: integer format: int32 - description: The index of the output item in the response. + description: The index of the output item in the Response. item: - allOf: - - $ref: '#/components/schemas/RealtimeResponseItem' - description: The item that was added. + $ref: '#/components/schemas/RealtimeConversationResponseItem' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a new Item is created during response generation. + description: Returned when a new Item is created during Response generation. RealtimeServerEventResponseOutputItemDone: type: object required: @@ -10506,18 +10685,16 @@ components: type: string enum: - response.output_item.done - description: The event type, must be "response.output_item.done". + description: The event type, must be `response.output_item.done`. response_id: type: string - description: The ID of the response to which the item belongs. + description: The ID of the Response to which the item belongs. output_index: type: integer format: int32 - description: The index of the output item in the response. + description: The index of the output item in the Response. item: - allOf: - - $ref: '#/components/schemas/RealtimeResponseItem' - description: The completed item. + $ref: '#/components/schemas/RealtimeConversationResponseItem' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' description: Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. @@ -10601,14 +10778,12 @@ components: type: string enum: - session.created - description: The event type, must be "session.created". + description: The event type, must be `session.created`. session: - allOf: - - $ref: '#/components/schemas/RealtimeResponseSession' - description: The session resource. + $ref: '#/components/schemas/RealtimeResponseSession' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a session is created. Emitted automatically when a new connection is established. + description: Returned when a Session is created. Emitted automatically when a new connection is established as the first server event. This event will contain the default Session configuration. RealtimeServerEventSessionUpdated: type: object required: @@ -10621,12 +10796,10 @@ components: - session.updated description: The event type, must be "session.updated". session: - allOf: - - $ref: '#/components/schemas/RealtimeResponseSession' - description: The updated session resource. + $ref: '#/components/schemas/RealtimeResponseSession' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a session is updated. + description: Returned when a session is updated with a `session.update` event, unless there is an error. RealtimeServerEventType: anyOf: - type: string @@ -10681,6 +10854,9 @@ components: format: duration allOf: - $ref: '#/components/schemas/RealtimeTurnDetection' + RealtimeSessionBase: + type: object + description: Realtime session object configuration. RealtimeTool: type: object required: diff --git a/.scripts/Edit-Serialization.ps1 b/.scripts/Edit-Serialization.ps1 index 4d7d79948..07de076b2 100644 --- a/.scripts/Edit-Serialization.ps1 +++ b/.scripts/Edit-Serialization.ps1 @@ -17,7 +17,7 @@ function Edit-Serialization { if ($content -cnotmatch $regex) { - throw "The code does not match the expected pattern. If this is by design, please update or disable this edit." + throw "The code does not match the expected pattern. If this is by design, please update or disable this edit.`n`n$regex" } else { @@ -40,6 +40,7 @@ function Edit-InternalChatCompletionResponseMessageSerialization { "return new InternalChatCompletionResponseMessage\(" " refusal," " toolCalls \?\? new ChangeTrackingList\(\)," + " audio," " role," " content," " functionCall," @@ -50,6 +51,7 @@ function Edit-InternalChatCompletionResponseMessageSerialization { "return new InternalChatCompletionResponseMessage(" " refusal," " toolCalls ?? new ChangeTrackingList()," + " audio," " role," " content ?? new ChatMessageContent()," " functionCall," @@ -74,6 +76,7 @@ function Edit-InternalChatCompletionStreamResponseDeltaSerialization { # content deserialization $inputRegex = @( "return new InternalChatCompletionStreamResponseDelta\(" + " audio," " functionCall," " toolCalls \?\? new ChangeTrackingList\(\)," " refusal," @@ -84,6 +87,7 @@ function Edit-InternalChatCompletionStreamResponseDeltaSerialization { $outputString = @( "// CUSTOM: Initialize Content collection property." "return new InternalChatCompletionStreamResponseDelta(" + " audio," " functionCall," " toolCalls ?? new ChangeTrackingList()," " refusal," @@ -111,38 +115,6 @@ function Edit-ChatMessageSerialization { # no-op } - -function Edit-AssistantChatMessageSerialization { - $filename = "AssistantChatMessage.Serialization.cs" - - # content serialization - # no-op - - # content deserialization - $inputRegex = @( - "return new AssistantChatMessage\(" - " role," - " content," - " additionalBinaryDataProperties," - " refusal," - " participantName," - " toolCalls \?\? new ChangeTrackingList\(\)," - " functionCall\);" - ) - $outputString = @( - "// CUSTOM: Initialize Content collection property." - "return new AssistantChatMessage(" - " role," - " content ?? new ChatMessageContent()," - " additionalBinaryDataProperties," - " refusal," - " participantName," - " toolCalls ?? new ChangeTrackingList()," - " functionCall);" - ) - Edit-Serialization -Filename $filename -InputRegex $inputRegex -OutputString $outputString -OutputIndentation 12 -} - function Edit-FunctionChatMessageSerialization { $filename = "FunctionChatMessage.Serialization.cs" @@ -151,11 +123,11 @@ function Edit-FunctionChatMessageSerialization { # content deserialization $inputRegex = @( - "return new FunctionChatMessage\(role, content, additionalBinaryDataProperties, functionName\);" + "return new FunctionChatMessage\(content, role, additionalBinaryDataProperties, functionName\);" ) $outputString = @( "// CUSTOM: Initialize Content collection property." - "return new FunctionChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties, functionName);" + "return new FunctionChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties, functionName);" ) Edit-Serialization -Filename $filename -InputRegex $inputRegex -OutputString $outputString -OutputIndentation 12 } @@ -168,11 +140,11 @@ function Edit-SystemChatMessageSerialization { # content deserialization $inputRegex = @( - "return new SystemChatMessage\(role, content, additionalBinaryDataProperties, participantName\);" + "return new SystemChatMessage\(content, role, additionalBinaryDataProperties, participantName\);" ) $outputString = @( "// CUSTOM: Initialize Content collection property." - "return new SystemChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties, participantName);" + "return new SystemChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties, participantName);" ) Edit-Serialization -Filename $filename -InputRegex $inputRegex -OutputString $outputString -OutputIndentation 12 } @@ -185,11 +157,11 @@ function Edit-ToolChatMessageSerialization { # content deserialization $inputRegex = @( - "return new ToolChatMessage\(role, content, additionalBinaryDataProperties, toolCallId\);" + "return new ToolChatMessage\(content, role, additionalBinaryDataProperties, toolCallId\);" ) $outputString = @( "// CUSTOM: Initialize Content collection property." - "return new ToolChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties, toolCallId);" + "return new ToolChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties, toolCallId);" ) Edit-Serialization -Filename $filename -InputRegex $inputRegex -OutputString $outputString -OutputIndentation 12 } @@ -202,11 +174,11 @@ function Edit-UserChatMessageSerialization { # content deserialization $inputRegex = @( - "return new UserChatMessage\(role, content, additionalBinaryDataProperties, participantName\);" + "return new UserChatMessage\(content, role, additionalBinaryDataProperties, participantName\);" ) $outputString = @( "// CUSTOM: Initialize Content collection property." - "return new UserChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties, participantName);" + "return new UserChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties, participantName);" ) Edit-Serialization -Filename $filename -InputRegex $inputRegex -OutputString $outputString -OutputIndentation 12 } @@ -219,11 +191,11 @@ function Edit-InternalUnknownChatMessageSerialization { # content deserialization $inputRegex = @( - "return new InternalUnknownChatMessage\(role, content, additionalBinaryDataProperties\);" + "return new InternalUnknownChatMessage\(content, role, additionalBinaryDataProperties\);" ) $outputString = @( "// CUSTOM: Initialize Content collection property." - "return new InternalUnknownChatMessage(role, content ?? new ChatMessageContent(), additionalBinaryDataProperties);" + "return new InternalUnknownChatMessage(content ?? new ChatMessageContent(), role, additionalBinaryDataProperties);" ) Edit-Serialization -Filename $filename -InputRegex $inputRegex -OutputString $outputString -OutputIndentation 12 } @@ -237,24 +209,26 @@ function Edit-InternalFineTuneChatCompletionRequestAssistantMessageSerialization # content deserialization $inputRegex = @( "return new InternalFineTuneChatCompletionRequestAssistantMessage\(" - " role," " content," + " role," " additionalBinaryDataProperties," " refusal," " participantName," " toolCalls \?\? new ChangeTrackingList\(\)," - " functionCall\);" + " functionCall," + " audio\);" ) $outputString = @( "// CUSTOM: Initialize Content collection property." "return new InternalFineTuneChatCompletionRequestAssistantMessage(" - " role," " content ?? new ChatMessageContent()," + " role," " additionalBinaryDataProperties," " refusal," " participantName," " toolCalls ?? new ChangeTrackingList()," - " functionCall);" + " functionCall," + " audio);" ) Edit-Serialization -Filename $filename -InputRegex $inputRegex -OutputString $outputString -OutputIndentation 12 } @@ -262,7 +236,6 @@ function Edit-InternalFineTuneChatCompletionRequestAssistantMessageSerialization Edit-InternalChatCompletionResponseMessageSerialization Edit-InternalChatCompletionStreamResponseDeltaSerialization Edit-ChatMessageSerialization -Edit-AssistantChatMessageSerialization Edit-FunctionChatMessageSerialization Edit-SystemChatMessageSerialization Edit-ToolChatMessageSerialization diff --git a/.scripts/Update-ClientModel.ps1 b/.scripts/Update-ClientModel.ps1 index e0e83c6e5..7089f0167 100644 --- a/.scripts/Update-ClientModel.ps1 +++ b/.scripts/Update-ClientModel.ps1 @@ -1,6 +1,6 @@ function Remove-MultipartFormDataBinaryContent { $root = Split-Path $PSScriptRoot -Parent - $filePath = Join-Path -Path $root -ChildPath ".dotnet\src\Generated\Internal\MultipartFormDataBinaryContent.cs" + $filePath = Join-Path -Path $root -ChildPath ".dotnet\src\Generated\Internal\MultiPartFormDataBinaryContent.cs" $file = Get-ChildItem -Path $filePath Write-Output "Removing $($file.FullName)" diff --git a/.typespec/chat/custom.tsp b/.typespec/chat/custom.tsp index b3db01297..ea6cc0684 100644 --- a/.typespec/chat/custom.tsp +++ b/.typespec/chat/custom.tsp @@ -29,3 +29,14 @@ model ChatCompletionToolChoice {} model ChatMessageContent {} model ChatMessageContentPart {} + +model ChatCompletionMessageAudioChunk { + id?: string; + transcript?: string; + + @encode("base64") + data?: bytes; + + @encode("unixTimestamp", int32) + expires_at?: utcDateTime; +} diff --git a/.typespec/chat/models.tsp b/.typespec/chat/models.tsp index 058a341e5..7563d5fe5 100644 --- a/.typespec/chat/models.tsp +++ b/.typespec/chat/models.tsp @@ -14,7 +14,12 @@ namespace OpenAI; model ChatCompletionTokenLogprobBytes is int32[]; model CreateChatCompletionRequest { - /** A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. */ + /** + * A list of messages comprising the conversation so far. Depending on the + * [model](/docs/models) you use, different message types (modalities) are + * supported, like [text](/docs/guides/text-generation), + * [images](/docs/guides/vision), and [audio](/docs/guides/audio). + */ @minItems(1) messages: ChatCompletionRequestMessage[]; @@ -31,6 +36,8 @@ model CreateChatCompletionRequest { | "gpt-4o-2024-05-13" | "gpt-4o-realtime-preview" | "gpt-4o-realtime-preview-2024-10-01" + | "gpt-4o-audio-preview" + | "gpt-4o-audio-preview-2024-10-01" | "chatgpt-4o-latest" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" @@ -113,6 +120,27 @@ model CreateChatCompletionRequest { @maxValue(128) n?: int32 | null = 1; + modalities?: ChatCompletionModalities | null; + + @doc(""" + Parameters for audio output. Required when audio output is requested with + `modalities: ["audio"]`. [Learn more](/docs/guides/audio). + """) + @extension("x-oaiExpandable", true) + audio?: { + @doc(""" + Specifies the voice type. Supported voices are `alloy`, `echo`, + `fable`, `onyx`, `nova`, and `shimmer`. + """) + voice: "alloy" | "echo" | "fable" | "onyx" | "nova" | "shimmer"; + + @doc(""" + Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, + `opus`, or `pcm16`. + """) + format: "wav" | "mp3" | "flac" | "opus" | "pcm16"; + } | null; + /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. * @@ -322,6 +350,7 @@ union ChatCompletionToolChoiceOption { ChatCompletionNamedToolChoice, } +/** Learn about [text inputs](/docs/guides/text-generation). */ model ChatCompletionRequestMessageContentPartText { /** The type of the content part. */ type: "text"; @@ -330,6 +359,7 @@ model ChatCompletionRequestMessageContentPartText { text: string; } +/** Learn about [image inputs](/docs/guides/vision). */ model ChatCompletionRequestMessageContentPartImage { /** The type of the content part. */ type: "image_url"; @@ -379,6 +409,24 @@ model ChatCompletionRequestMessage { role: string; } +/** Learn about [audio inputs](/docs/guides/audio). */ +model ChatCompletionRequestMessageContentPartAudio { + @doc(""" + The type of the content part. Always `input_audio`. + """) + type: "input_audio"; + + input_audio: { + // Tool customization: use encoded type for audio data + /** Base64 encoded audio data. */ + @encode("base64") + data: bytes; + + /** The format of the encoded audio data. Currently supports "wav" and "mp3". */ + format: "wav" | "mp3"; + }; +} + @extension("x-oaiExpandable", true) union ChatCompletionRequestSystemMessageContentPart { ChatCompletionRequestMessageContentPartText, @@ -388,6 +436,7 @@ union ChatCompletionRequestSystemMessageContentPart { union ChatCompletionRequestUserMessageContentPart { ChatCompletionRequestMessageContentPartText, ChatCompletionRequestMessageContentPartImage, + ChatCompletionRequestMessageContentPartAudio, } @extension("x-oaiExpandable", true) @@ -450,6 +499,16 @@ model ChatCompletionRequestAssistantMessage /** An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ name?: string; + /** + * Data about a previous audio response from the model. + * [Learn more](/docs/guides/audio). + */ + @extension("x-oaiExpandable", true) + audio?: { + /** Unique identifier for a previous audio response from the model. */ + id: string; + } | null; + tool_calls?: ChatCompletionMessageToolCalls; // Tool customization: preserve earlier, more intuitive field order @@ -496,6 +555,20 @@ model ChatCompletionRequestFunctionMessage /** The tool calls generated by the model, such as function calls. */ model ChatCompletionMessageToolCalls is ChatCompletionMessageToolCall[]; +@doc(""" + Output types that you would like the model to generate for this request. + Most models are capable of generating text, which is the default: + + `["text"]` + + The `gpt-4o-audio-preview` model can also be used to [generate audio](/docs/guides/audio). To + request that this model generate both text and audio responses, you can + use: + + `["text", "audio"]` + """) +model ChatCompletionModalities is ("text" | "audio")[]; + // Tool customization: convert to enum /** The role of the author of a message */ enum ChatCompletionRole { @@ -571,6 +644,36 @@ model ChatCompletionResponseMessage { name: string; arguments: string; }; + + /** + * If the audio output modality is requested, this object contains data + * about the audio response from the model. [Learn more](/docs/guides/audio). + */ + @extension("x-oaiExpandable", true) + audio?: { + /** Unique identifier for this audio response. */ + id: string; + + // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime + /** + * The Unix timestamp (in seconds) for when this audio response will + * no longer be accessible on the server for use in multi-turn + * conversations. + */ + @encode("unixTimestamp", int32) + expires_at: utcDateTime; + + // Tool customization: use encoded type for audio data + /** + * Base64 encoded audio bytes generated by the model, in the format + * specified in the request. + */ + @encode("base64") + data: bytes; + + /** Transcript of the audio generated by the model. */ + transcript: string; + } | null; } model ChatCompletionTokenLogprob { @@ -625,8 +728,12 @@ model ChatCompletionFunctions { parameters?: FunctionParameters; } +// Tool customization: Add a missing "audio" to the chat streaming delta definition /** A chat completion delta generated by streamed model responses. */ model ChatCompletionStreamResponseDelta { + /** Response audio associated with the streaming chat delta payload. */ + audio?: ChatCompletionMessageAudioChunk; + /** The contents of the chunk message. */ content?: string | null; @@ -748,7 +855,7 @@ model CreateChatCompletionStreamResponse { /** Total number of tokens used in the request (prompt + completion). */ total_tokens: int32; - }; + } | null; } /** Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ diff --git a/.typespec/realtime/custom.tsp b/.typespec/realtime/custom.tsp index cb2588bea..3ce8eff8d 100644 --- a/.typespec/realtime/custom.tsp +++ b/.typespec/realtime/custom.tsp @@ -7,6 +7,7 @@ using TypeSpec.OpenAPI; namespace OpenAI; model RealtimeRequestSession { + ...RealtimeSessionBase; modalities?: RealtimeModalities; instructions?: string; voice?: RealtimeVoice; @@ -17,17 +18,65 @@ model RealtimeRequestSession { tools?: RealtimeTool[]; tool_choice?: RealtimeToolChoice; temperature?: float32; - - // Note: spec errata for 'max_output_tokens' max_response_output_tokens?: int32 | "inf"; } +model RealtimeResponseSession { + ...RealtimeSessionBase; + object: "realtime.session"; + id: string; + `model`: string; + modalities: RealtimeModalities; + instructions: string; + voice: RealtimeVoice; + input_audio_format: RealtimeAudioFormat; + output_audio_format: RealtimeAudioFormat; + input_audio_transcription: RealtimeAudioInputTranscriptionSettings | null; + turn_detection: RealtimeTurnDetection; + tools: RealtimeTool[]; + tool_choice: RealtimeToolChoice; + temperature: float32; + max_response_output_tokens: int32 | "inf" | null; +} + +model RealtimeResponseOptions { + ...RealtimeResponseBase; + + /** The modalities for the response. */ + modalities?: RealtimeModalities; + + /** Instructions for the model. */ + instructions?: string; + + @doc(""" + The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. + """) + voice?: RealtimeVoice; + + /** The format of output audio. */ + output_audio_format?: RealtimeAudioFormat; + + // Tool customization: apply enriched tool definition hierarchy + /** Tools (functions) available to the model. */ + tools?: RealtimeTool[]; + + /** How the model chooses tools. */ + tool_choice?: RealtimeToolChoice; + + /** Sampling temperature. */ + temperature?: float32; + + /** Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf". */ + max_output_tokens?: int32 | "inf"; +} + model RealtimeResponse { + ...RealtimeResponseBase; object: "realtime.response"; id: string; status: RealtimeResponseStatus = RealtimeResponseStatus.in_progress; status_details: RealtimeResponseStatusDetails | null; - output: RealtimeResponseItem[]; + output: RealtimeConversationResponseItem[]; usage: { total_tokens: int32; input_tokens: int32; @@ -44,23 +93,6 @@ model RealtimeResponse { }; } -model RealtimeResponseSession { - object: "realtime.session"; - id: string; - `model`: string; - modalities: RealtimeModalities; - instructions: string; - voice: RealtimeVoice; - input_audio_format: RealtimeAudioFormat; - output_audio_format: RealtimeAudioFormat; - input_audio_transcription: RealtimeAudioInputTranscriptionSettings | null; - turn_detection: RealtimeTurnDetection; - tools: RealtimeTool[]; - tool_choice: RealtimeToolChoice; - temperature: float32; - max_response_output_tokens: int32 | "inf" | null; -} - union RealtimeVoice { string, alloy: "alloy", diff --git a/.typespec/realtime/custom/items.tsp b/.typespec/realtime/custom/items.tsp index 8e939b412..43ae09ef2 100644 --- a/.typespec/realtime/custom/items.tsp +++ b/.typespec/realtime/custom/items.tsp @@ -5,13 +5,14 @@ using TypeSpec.OpenAPI; namespace OpenAI; @discriminator("type") -model RealtimeRequestItem { +model RealtimeConversationRequestItem { + ...RealtimeConversationItemBase; type: RealtimeItemType; id?: string; } @discriminator("role") -model RealtimeRequestMessageItem extends RealtimeRequestItem { +model RealtimeRequestMessageItem extends RealtimeConversationRequestItem { type: RealtimeItemType.message; role: RealtimeMessageRole; status?: RealtimeItemStatus; @@ -32,7 +33,7 @@ model RealtimeRequestAssistantMessageItem extends RealtimeRequestMessageItem { content: RealtimeRequestTextContentPart[]; } -model RealtimeRequestFunctionCallItem extends RealtimeRequestItem { +model RealtimeRequestFunctionCallItem extends RealtimeConversationRequestItem { type: RealtimeItemType.function_call; name: string; call_id: string; @@ -40,7 +41,8 @@ model RealtimeRequestFunctionCallItem extends RealtimeRequestItem { status?: RealtimeItemStatus; } -model RealtimeRequestFunctionCallOutputItem extends RealtimeRequestItem { +model RealtimeRequestFunctionCallOutputItem + extends RealtimeConversationRequestItem { type: RealtimeItemType.function_call_output; call_id: string; output: string; @@ -49,26 +51,28 @@ model RealtimeRequestFunctionCallOutputItem extends RealtimeRequestItem { // TODO: representation of a doubly-discriminated type with an absent second discriminator // (first discriminator: type = message; second discriminator: no role present) -model RealtimeRequestMessageReferenceItem { // extends RealtimeRequestItem { +model RealtimeRequestMessageReferenceItem { // extends RealtimeConversationRequestItem { type: RealtimeItemType.message; id: string; } @discriminator("type") -model RealtimeResponseItem { +model RealtimeConversationResponseItem { + ...RealtimeConversationItemBase; object: "realtime.item"; type: RealtimeItemType; id: string | null; } -model RealtimeResponseMessageItem extends RealtimeResponseItem { +model RealtimeResponseMessageItem extends RealtimeConversationResponseItem { type: RealtimeItemType.message; role: RealtimeMessageRole; content: RealtimeContentPart[]; status: RealtimeItemStatus; } -model RealtimeResponseFunctionCallItem extends RealtimeResponseItem { +model RealtimeResponseFunctionCallItem + extends RealtimeConversationResponseItem { type: RealtimeItemType.function_call; name: string; call_id: string; @@ -76,7 +80,8 @@ model RealtimeResponseFunctionCallItem extends RealtimeResponseItem { status: RealtimeItemStatus; } -model RealtimeResponseFunctionCallOutputItem extends RealtimeResponseItem { +model RealtimeResponseFunctionCallOutputItem + extends RealtimeConversationResponseItem { type: RealtimeItemType.function_call_output; call_id: string; output: string; diff --git a/.typespec/realtime/models.tsp b/.typespec/realtime/models.tsp index 047c48f9c..0826558f8 100644 --- a/.typespec/realtime/models.tsp +++ b/.typespec/realtime/models.tsp @@ -10,32 +10,53 @@ using TypeSpec.OpenAPI; namespace OpenAI; // Tool customization: apply discriminated type base -/** Send this event to update the session’s default configuration. */ +@doc(""" + Send this event to update the session’s default configuration. The client may send this event at any time to update the session configuration, and any field may be updated at any time, except for "voice". The server will respond with a `session.updated` event that shows the full effective configuration. Only fields that are present are updated, thus the correct way to clear a field like "instructions" is to pass an empty string. + """) model RealtimeClientEventSessionUpdate extends RealtimeClientEvent { // Tool customization: apply discriminated type base /** The event type, must be "session.update". */ type: RealtimeClientEventType.session_update; - // Tool customization: apply shared session type - /** Session configuration to update. */ + // Tool customization: apply enriched request-specific model session: RealtimeRequestSession; } +// Tool customization: establish custom, enriched discriminated type hierarchy +/** The item to add to the conversation. */ +model RealtimeConversationItemBase { + /** Customized to enriched RealtimeConversation{Request,Response}Item models */ +} + +// Tool customization: apply enriched response type +/** The response resource. */ +model RealtimeResponseBase { + /** applied in enriched RealtimeResponse */ +} + // Tool customization: apply discriminated type base -/** Send this event to append audio bytes to the input audio buffer. */ +/** + * Send this event to append audio bytes to the input audio buffer. The audio buffer is temporary storage you can write to and later commit. In Server VAD mode, the audio buffer is used to detect speech and the server will decide when to commit. When Server VAD is disabled, you must commit the audio buffer manually. + * The client may choose how much audio to place in each event up to a maximum of 15 MiB, for example streaming smaller chunks from the client may allow the VAD to be more responsive. Unlike made other client events, the server will not send a confirmation response to this event. + */ model RealtimeClientEventInputAudioBufferAppend extends RealtimeClientEvent { // Tool customization: apply discriminated type base /** The event type, must be "input_audio_buffer.append". */ type: RealtimeClientEventType.input_audio_buffer_append; // Tool customization: use encoded type for audio data - /** Base64-encoded audio bytes. */ + @doc(""" + Base64-encoded audio bytes. This must be in the format specified by the `input_audio_format` field in the session configuration. + """) @encode("base64") audio: bytes; } // Tool customization: apply discriminated type base -/** Send this event to commit audio bytes to a user message. */ +@doc(""" + Send this event to commit the user input audio buffer, which will create a new user message item in the conversation. This event will produce an error if the input audio buffer is empty. When in Server VAD mode, the client does not need to send this event, the server will commit the audio buffer automatically. + Committing the input audio buffer will trigger input audio transcription (if enabled in session configuration), but it will not create a response from the model. The server will respond with an `input_audio_buffer.committed` event. + """) model RealtimeClientEventInputAudioBufferCommit extends RealtimeClientEvent { // Tool customization: apply discriminated type base /** The event type, must be "input_audio_buffer.commit". */ @@ -43,7 +64,9 @@ model RealtimeClientEventInputAudioBufferCommit extends RealtimeClientEvent { } // Tool customization: apply discriminated type base -/** Send this event to clear the audio bytes in the buffer. */ +@doc(""" + Send this event to clear the audio bytes in the buffer. The server will respond with an `input_audio_buffer.cleared` event. + """) model RealtimeClientEventInputAudioBufferClear extends RealtimeClientEvent { // Tool customization: apply discriminated type base /** The event type, must be "input_audio_buffer.clear". */ @@ -51,39 +74,49 @@ model RealtimeClientEventInputAudioBufferClear extends RealtimeClientEvent { } // Tool customization: apply discriminated type base -/** Send this event when adding an item to the conversation. */ +@doc(""" + Add a new Item to the Conversation's context, including messages, function calls, and function call responses. This event can be used both to populate a "history" of the conversation and to add new items mid-stream, but has the current limitation that it cannot populate assistant audio messages. + If successful, the server will respond with a `conversation.item.created` event, otherwise an `error` event will be sent. + """) model RealtimeClientEventConversationItemCreate extends RealtimeClientEvent { // Tool customization: apply discriminated type base - /** The event type, must be "conversation.item.create". */ + @doc(""" + The event type, must be `conversation.item.create`. + """) type: RealtimeClientEventType.conversation_item_create; - /** The ID of the preceding item after which the new item will be inserted. */ + /** The ID of the preceding item after which the new item will be inserted. If not set, the new item will be appended to the end of the conversation. If set, it allows an item to be inserted mid-conversation. If the ID cannot be found, an error will be returned and the item will not be added. */ previous_item_id?: string; // Tool customization: apply enriched item definition hierarchy - /** The item to add to the conversation. */ - item: RealtimeRequestItem; + item: RealtimeConversationRequestItem; } // Tool customization: apply discriminated type base -/** Send this event when you want to truncate a previous assistant message’s audio. */ +@doc(""" + Send this event to truncate a previous assistant message’s audio. The server will produce audio faster than realtime, so this event is useful when the user interrupts to truncate audio that has already been sent to the client but not yet played. This will synchronize the server's understanding of the audio with the client's playback. + Truncating audio will delete the server-side text transcript to ensure there is not text in the context that hasn't been heard by the user. + If successful, the server will respond with a `conversation.item.truncated` event. + """) model RealtimeClientEventConversationItemTruncate extends RealtimeClientEvent { // Tool customization: apply discriminated type base /** The event type, must be "conversation.item.truncate". */ type: RealtimeClientEventType.conversation_item_truncate; - /** The ID of the assistant message item to truncate. */ + /** The ID of the assistant message item to truncate. Only assistant message items can be truncated. */ item_id: string; - /** The index of the content part to truncate. */ + /** The index of the content part to truncate. Set this to 0. */ content_index: int32; - /** Inclusive duration up to which audio is truncated, in milliseconds. */ + /** Inclusive duration up to which audio is truncated, in milliseconds. If the audio_end_ms is greater than the actual audio duration, the server will respond with an error. */ audio_end_ms: int32; } // Tool customization: apply discriminated type base -/** Send this event when you want to remove any item from the conversation history. */ +@doc(""" + Send this event when you want to remove any item from the conversation history. The server will respond with a `conversation.item.deleted` event, unless the item does not exist in the conversation history, in which case the server will respond with an error. + """) model RealtimeClientEventConversationItemDelete extends RealtimeClientEvent { // Tool customization: apply discriminated type base /** The event type, must be "conversation.item.delete". */ @@ -94,53 +127,37 @@ model RealtimeClientEventConversationItemDelete extends RealtimeClientEvent { } // Tool customization: apply discriminated type base -/** Send this event to trigger a response generation. */ +@doc(""" + This event instructs the server to create a Response, which means triggering model inference. When in Server VAD mode, the server will create Responses automatically. + A Response will include at least one Item, and may have two, in which case the second will be a function call. These Items will be appended to the conversation history. + The server will respond with a `response.created` event, events for Items and content created, and finally a `response.done` event to indicate the Response is complete. + The `response.create` event includes inference configuration like `instructions`, and `temperature`. These fields will override the Session's configuration for this Response only. + """) model RealtimeClientEventResponseCreate extends RealtimeClientEvent { // Tool customization: apply discriminated type base - /** The event type, must be "response.create". */ + @doc(""" + The event type, must be `response.create`. + """) type: RealtimeClientEventType.response_create; - /** Configuration for the response. */ - response: { - /** The modalities for the response. */ - modalities?: string[]; - - /** Instructions for the model. */ - instructions?: string; - - @doc(""" - The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. - """) - voice?: string; - - /** The format of output audio. */ - output_audio_format?: string; - - // Tool customization: apply enriched tool definition hierarchy - /** Tools (functions) available to the model. */ - tools?: RealtimeTool[]; - - /** How the model chooses tools. */ - tool_choice?: string; - - /** Sampling temperature. */ - temperature?: float32; - - /** Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf". */ - max_output_tokens?: int32 | "inf"; - }; + // Tool customization: apply custom, distinct type for request-side response options + response: RealtimeResponseOptions; } // Tool customization: apply discriminated type base -/** Send this event to cancel an in-progress response. */ +@doc(""" + Send this event to cancel an in-progress response. The server will respond with a `response.cancelled` event or an error if there is no response to cancel. + """) model RealtimeClientEventResponseCancel extends RealtimeClientEvent { // Tool customization: apply discriminated type base - /** The event type, must be "response.cancel". */ + @doc(""" + The event type, must be `response.cancel`. + """) type: RealtimeClientEventType.response_cancel; } // Tool customization: apply discriminated type base -/** Returned when an error occurs. */ +/** Returned when an error occurs, which could be a client problem or a server problem. Most errors are recoverable and the session will stay open, we recommend to implementors to monitor and log error messages by default. */ model RealtimeServerEventError extends RealtimeServerEvent { // Tool customization: apply discriminated type /** The event type, must be "error". */ @@ -166,29 +183,35 @@ model RealtimeServerEventError extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when a session is created. Emitted automatically when a new connection is established. */ +/** Returned when a Session is created. Emitted automatically when a new connection is established as the first server event. This event will contain the default Session configuration. */ model RealtimeServerEventSessionCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "session.created". */ + @doc(""" + The event type, must be `session.created`. + """) type: RealtimeServerEventType.session_created; - // Tool customization: apply shared session type - /** The session resource. */ + // Tool customization: apply enriched response-specific model session: RealtimeResponseSession; } // Tool customization: apply discriminated type base -/** Returned when a session is updated. */ +@doc(""" + Returned when a session is updated with a `session.update` event, unless there is an error. + """) model RealtimeServerEventSessionUpdated extends RealtimeServerEvent { // Tool customization: apply discriminated type /** The event type, must be "session.updated". */ type: RealtimeServerEventType.session_updated; - // Tool customization: apply shared session type - /** The updated session resource. */ + // Tool customization: apply enriched response-specific model session: RealtimeResponseSession; } +// Tool customization: establish base for enriched request/response split models +/** Realtime session object configuration. */ +model RealtimeSessionBase {} + // Tool customization: apply discriminated type base /** Returned when a conversation is created. Emitted right after session creation. */ model RealtimeServerEventConversationCreated extends RealtimeServerEvent { @@ -207,10 +230,14 @@ model RealtimeServerEventConversationCreated extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. */ +@doc(""" + Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. The `item_id` property is the ID of the user message item that will be created, thus a `conversation.item.created` event will also be sent to the client. + """) model RealtimeServerEventInputAudioBufferCommitted extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "input_audio_buffer.committed". */ + @doc(""" + The event type, must be `input_audio_buffer.committed`. + """) type: RealtimeServerEventType.input_audio_buffer_committed; /** The ID of the preceding item after which the new item will be inserted. */ @@ -221,22 +248,32 @@ model RealtimeServerEventInputAudioBufferCommitted extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when the input audio buffer is cleared by the client. */ +@doc(""" + Returned when the input audio buffer is cleared by the client with a `input_audio_buffer.clear` event. + """) model RealtimeServerEventInputAudioBufferCleared extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "input_audio_buffer.cleared". */ + @doc(""" + The event type, must be `input_audio_buffer.cleared`. + """) type: RealtimeServerEventType.input_audio_buffer_cleared; } // Tool customization: apply discriminated type base -/** Returned in server turn detection mode when speech is detected. */ +@doc(""" + Sent by the server when in `server_vad` mode to indicate that speech has been detected in the audio buffer. This can happen any time audio is added to the buffer (unless speech is already detected). The client may want to use this event to interrupt audio playback or provide visual feedback to the user. The client should expect to receive a `input_audio_buffer.speech_stopped` event when speech stops. The `item_id` property is the ID of the user message item that will be created when speech stops and will also be included in the `input_audio_buffer.speech_stopped` event (unless the client manually commits the audio buffer during VAD activation). + """) model RealtimeServerEventInputAudioBufferSpeechStarted extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "input_audio_buffer.speech_started". */ + @doc(""" + The event type, must be `input_audio_buffer.speech_started`. + """) type: RealtimeServerEventType.input_audio_buffer_speech_started; - /** Milliseconds since the session started when speech was detected. */ + @doc(""" + Milliseconds from the start of all audio written to the buffer during the session when speech was first detected. This will correspond to the beginning of audio sent to the model, and thus includes the `prefix_padding_ms` configured in the Session. + """) audio_start_ms: int32; /** The ID of the user message item that will be created when speech stops. */ @@ -244,14 +281,20 @@ model RealtimeServerEventInputAudioBufferSpeechStarted } // Tool customization: apply discriminated type base -/** Returned in server turn detection mode when speech stops. */ +@doc(""" + Returned in `server_vad` mode when the server detects the end of speech in the audio buffer. The server will also send an `conversation.item.created` event with the user message item that is created from the audio buffer. + """) model RealtimeServerEventInputAudioBufferSpeechStopped extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "input_audio_buffer.speech_stopped". */ + @doc(""" + The event type, must be `input_audio_buffer.speech_stopped`. + """) type: RealtimeServerEventType.input_audio_buffer_speech_stopped; - /** Milliseconds since the session started when speech stopped. */ + @doc(""" + Milliseconds since the session started when speech stopped. This will correspond to the end of audio sent to the model, and thus includes the `min_silence_duration_ms` configured in the Session. + """) audio_end_ms: int32; /** The ID of the user message item that will be created. */ @@ -259,29 +302,40 @@ model RealtimeServerEventInputAudioBufferSpeechStopped } // Tool customization: apply discriminated type base -/** Returned when a conversation item is created. */ +@doc(""" + Returned when a conversation item is created. There are several scenarios that produce this event: + - The server is generating a Response, which if successful will produce either one or two Items, which will be of type `message` (role `assistant`) or type `function_call`. + - The input audio buffer has been committed, either by the client or the server (in `server_vad` mode). The server will take the content of the input audio buffer and add it to a new user message Item. + - The client has sent a `conversation.item.create` event to add a new Item to the Conversation. + """) model RealtimeServerEventConversationItemCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "conversation.item.created". */ + @doc(""" + The event type, must be `conversation.item.created`. + """) type: RealtimeServerEventType.conversation_item_created; - /** The ID of the preceding item. */ + /** The ID of the preceding item in the Conversation context, allows the client to understand the order of the conversation. */ previous_item_id: string; // Tool customization: apply enriched item definition hierarchy - /** The item that was created. */ - item: RealtimeResponseItem; + item: RealtimeConversationResponseItem; } // Tool customization: apply discriminated type base -/** Returned when input audio transcription is enabled and a transcription succeeds. */ +@doc(""" + This event is the output of audio transcription for user audio written to the user audio buffer. Transcription begins when the input audio buffer is committed by the client or server (in `server_vad` mode). Transcription runs asynchronously with Response creation, so this event may come before or after the Response events. + Realtime API models accept audio natively, and thus input transcription is a separate process run on a separate ASR (Automatic Speech Recognition) model, currently always `whisper-1`. Thus the transcript may diverge somewhat from the model's interpretation, and should be treated as a rough guide. + """) model RealtimeServerEventConversationItemInputAudioTranscriptionCompleted extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "conversation.item.input_audio_transcription.completed". */ + @doc(""" + The event type, must be `conversation.item.input_audio_transcription.completed`. + """) type: RealtimeServerEventType.conversation_item_input_audio_transcription_completed; - /** The ID of the user message item. */ + /** The ID of the user message item containing the audio. */ item_id: string; /** The index of the content part containing the audio. */ @@ -292,11 +346,15 @@ model RealtimeServerEventConversationItemInputAudioTranscriptionCompleted } // Tool customization: apply discriminated type base -/** Returned when input audio transcription is configured, and a transcription request for a user message failed. */ +@doc(""" + Returned when input audio transcription is configured, and a transcription request for a user message failed. These events are separate from other `error` events so that the client can identify the related Item. + """) model RealtimeServerEventConversationItemInputAudioTranscriptionFailed extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "conversation.item.input_audio_transcription.failed". */ + @doc(""" + The event type, must be `conversation.item.input_audio_transcription.failed`. + """) type: RealtimeServerEventType.conversation_item_input_audio_transcription_failed; /** The ID of the user message item. */ @@ -322,10 +380,15 @@ model RealtimeServerEventConversationItemInputAudioTranscriptionFailed } // Tool customization: apply discriminated type base -/** Returned when an earlier assistant audio message item is truncated by the client. */ +@doc(""" + Returned when an earlier assistant audio message item is truncated by the client with a `conversation.item.truncate` event. This event is used to synchronize the server's understanding of the audio with the client's playback. + This action will truncate the audio and remove the server-side text transcript to ensure there is no text in the context that hasn't been heard by the user. + """) model RealtimeServerEventConversationItemTruncated extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "conversation.item.truncated". */ + @doc(""" + The event type, must be `conversation.item.truncated`. + """) type: RealtimeServerEventType.conversation_item_truncated; /** The ID of the assistant message item that was truncated. */ @@ -339,10 +402,14 @@ model RealtimeServerEventConversationItemTruncated extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when an item in the conversation is deleted. */ +@doc(""" + Returned when an item in the conversation is deleted by the client with a `conversation.item.delete` event. This event is used to synchronize the server's understanding of the conversation history with the client's view. + """) model RealtimeServerEventConversationItemDeleted extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "conversation.item.deleted". */ + @doc(""" + The event type, must be `conversation.item.deleted`. + """) type: RealtimeServerEventType.conversation_item_deleted; /** The ID of the item that was deleted. */ @@ -350,63 +417,67 @@ model RealtimeServerEventConversationItemDeleted extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when a new Response is created. The first event of response creation, where the response is in an initial state of "in_progress". */ +@doc(""" + Returned when a new Response is created. The first event of response creation, where the response is in an initial state of `in_progress`. + """) model RealtimeServerEventResponseCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.created". */ + @doc(""" + The event type, must be `response.created`. + """) type: RealtimeServerEventType.response_created; - // Tool customization: apply shared response type - /** The response resource. */ response: RealtimeResponse; } // Tool customization: apply discriminated type base -/** Returned when a Response is done streaming. Always emitted, no matter the final state. */ +@doc(""" + Returned when a Response is done streaming. Always emitted, no matter the final state. The Response object included in the `response.done` event will include all output Items in the Response but will omit the raw audio data. + """) model RealtimeServerEventResponseDone extends RealtimeServerEvent { // Tool customization: apply discriminated type /** The event type, must be "response.done". */ type: RealtimeServerEventType.response_done; - // Tool customization: apply shared response type - /** The response resource. */ response: RealtimeResponse; } // Tool customization: apply discriminated type base -/** Returned when a new Item is created during response generation. */ +/** Returned when a new Item is created during Response generation. */ model RealtimeServerEventResponseOutputItemAdded extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.output_item.added". */ + @doc(""" + The event type, must be `response.output_item.added`. + """) type: RealtimeServerEventType.response_output_item_added; - /** The ID of the response to which the item belongs. */ + /** The ID of the Response to which the item belongs. */ response_id: string; - /** The index of the output item in the response. */ + /** The index of the output item in the Response. */ output_index: int32; // Tool customization: apply enriched item definition hierarchy - /** The item that was added. */ - item: RealtimeResponseItem; + item: RealtimeConversationResponseItem; } // Tool customization: apply discriminated type base /** Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. */ model RealtimeServerEventResponseOutputItemDone extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.output_item.done". */ + @doc(""" + The event type, must be `response.output_item.done`. + """) type: RealtimeServerEventType.response_output_item_done; - /** The ID of the response to which the item belongs. */ + /** The ID of the Response to which the item belongs. */ response_id: string; - /** The index of the output item in the response. */ + /** The index of the output item in the Response. */ output_index: int32; // Tool customization: apply enriched item definition hierarchy - /** The completed item. */ - item: RealtimeResponseItem; + item: RealtimeConversationResponseItem; } // Tool customization: apply discriminated type base @@ -645,10 +716,12 @@ model RealtimeServerEventResponseFunctionCallArgumentsDone } // Tool customization: apply discriminated type base -/** Emitted after every "response.done" event to indicate the updated rate limits. */ +/** Emitted at the beginning of a Response to indicate the updated rate limits. When a Response is created some tokens will be "reserved" for the output tokens, the rate limits shown here reflect that reservation, which is then adjusted accordingly once the Response is completed. */ model RealtimeServerEventRateLimitsUpdated extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "rate_limits.updated". */ + @doc(""" + The event type, must be `rate_limits.updated`. + """) type: RealtimeServerEventType.rate_limits_updated; // Tool customization: use custom type for rate limit items (applying encoded duration) diff --git a/README.md b/README.md index fac2ff08e..ed5c9897a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # A conversion of the OpenAI OpenAPI to TypeSpec -Snapshot: 9da44b1e126916bbd4ab0bd62accf5622a3ec6ba -Ingestion tool: https://github.com/trrwilson/OpenApiToTsp@fa8e27d +For information on spec ingestion, see the Sorento wiki page: +https://dev.azure.com/project-argos/Sorento/_wiki/wikis/Sorento.wiki/3021/Generate-OpenAI's-YAML-Spec + +Snapshot: https://project-argos@dev.azure.com/project-argos/Sorento/_git/export-api@54593e37 +Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk@da3aa64 There are some deltas: diff --git a/openapi3-original.yaml b/openapi3-original.yaml index 3dd6e4681..684a653b5 100644 --- a/openapi3-original.yaml +++ b/openapi3-original.yaml @@ -1330,7 +1330,14 @@ paths: operationId: createChatCompletion tags: - Chat - summary: Creates a model response for the given chat conversation. + summary: > + Creates a model response for the given chat conversation. Learn more in + the + + [text generation](/docs/guides/text-generation), + [vision](/docs/guides/vision), + + and [audio](/docs/guides/audio) guides. requestBody: required: true content: @@ -10770,6 +10777,32 @@ components: description: The tool calls generated by the model, such as function calls. items: $ref: "#/components/schemas/ChatCompletionMessageToolCall" + ChatCompletionModalities: + type: array + nullable: true + description: > + Output types that you would like the model to generate for this request. + + Most models are capable of generating text, which is the default: + + + `["text"]` + + + The `gpt-4o-audio-preview` model can also be used to [generate + audio](/docs/guides/audio). To + + request that this model generate both text and audio responses, you can + + use: + + + `["text", "audio"]` + items: + type: string + enum: + - text + - audio ChatCompletionNamedToolChoice: type: object description: Specifies a tool the model should use. Use to force the model to @@ -10825,6 +10858,20 @@ components: type: string description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + audio: + type: object + nullable: true + x-oaiExpandable: true + description: | + Data about a previous audio response from the model. + [Learn more](/docs/guides/audio). + required: + - id + properties: + id: + type: string + description: | + Unique identifier for a previous audio response from the model. tool_calls: $ref: "#/components/schemas/ChatCompletionMessageToolCalls" function_call: @@ -10883,9 +10930,42 @@ components: - $ref: "#/components/schemas/ChatCompletionRequestToolMessage" - $ref: "#/components/schemas/ChatCompletionRequestFunctionMessage" x-oaiExpandable: true + ChatCompletionRequestMessageContentPartAudio: + type: object + title: Audio content part + description: | + Learn about [audio inputs](/docs/guides/audio). + properties: + type: + type: string + enum: + - input_audio + description: The type of the content part. Always `input_audio`. + input_audio: + type: object + properties: + data: + type: string + description: Base64 encoded audio data. + format: + type: string + enum: + - wav + - mp3 + description: > + The format of the encoded audio data. Currently supports "wav" + and "mp3". + required: + - data + - format + required: + - type + - input_audio ChatCompletionRequestMessageContentPartImage: type: object title: Image content part + description: | + Learn about [image inputs](/docs/guides/vision). properties: type: type: string @@ -10931,6 +11011,8 @@ components: ChatCompletionRequestMessageContentPartText: type: object title: Text content part + description: | + Learn about [text inputs](/docs/guides/text-generation). properties: type: type: string @@ -11021,10 +11103,9 @@ components: description: The text contents of the message. title: Text content - type: array - description: An array of content parts with a defined type, each can be of type - `text` or `image_url` when passing in images. You can pass - multiple images by adding multiple `image_url` content parts. - Image input is only supported when using the `gpt-4o` model. + description: An array of content parts with a defined type. Supported options + differ based on the [model](/docs/models) being used to generate + the response. Can contain text, image, or audio inputs. title: Array of content parts items: $ref: "#/components/schemas/ChatCompletionRequestUserMessageContentPart" @@ -11046,6 +11127,7 @@ components: oneOf: - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartText" - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartImage" + - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartAudio" x-oaiExpandable: true ChatCompletionResponseMessage: type: object @@ -11085,6 +11167,41 @@ components: required: - name - arguments + audio: + type: object + nullable: true + description: > + If the audio output modality is requested, this object contains data + + about the audio response from the model. [Learn + more](/docs/guides/audio). + x-oaiExpandable: true + required: + - id + - expires_at + - data + - transcript + properties: + id: + type: string + description: Unique identifier for this audio response. + expires_at: + type: integer + description: > + The Unix timestamp (in seconds) for when this audio response + will + + no longer be accessible on the server for use in multi-turn + + conversations. + data: + type: string + description: | + Base64 encoded audio bytes generated by the model, in the format + specified in the request. + transcript: + type: string + description: Transcript of the audio generated by the model. required: - role - content @@ -11685,10 +11802,14 @@ components: messages: description: > A list of messages comprising the conversation so far. Depending on - the [model](/docs/models) you use, different message types - (modalities) are supported, like - [text](/docs/guides/text-generation), [images](/docs/guides/vision), - and audio. + the + + [model](/docs/models) you use, different message types (modalities) + are + + supported, like [text](/docs/guides/text-generation), + + [images](/docs/guides/vision), and [audio](/docs/guides/audio). type: array minItems: 1 items: @@ -11712,6 +11833,8 @@ components: - gpt-4o-2024-08-06 - gpt-4o-realtime-preview - gpt-4o-realtime-preview-2024-10-01 + - gpt-4o-audio-preview + - gpt-4o-audio-preview-2024-10-01 - chatgpt-4o-latest - gpt-4o-mini - gpt-4o-mini-2024-07-18 @@ -11832,6 +11955,46 @@ components: message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + modalities: + $ref: "#/components/schemas/ChatCompletionModalities" + audio: + type: object + nullable: true + description: > + Parameters for audio output. Required when audio output is requested + with + + `modalities: ["audio"]`. [Learn more](/docs/guides/audio). + required: + - voice + - format + x-oaiExpandable: true + properties: + voice: + type: string + enum: + - alloy + - echo + - fable + - onyx + - nova + - shimmer + description: | + Specifies the voice type. Supported voices are `alloy`, `echo`, + `fable`, `onyx`, `nova`, and `shimmer`. + format: + type: string + enum: + - wav + - mp3 + - flac + - opus + - pcm16 + description: > + Specifies the output audio format. Must be one of `wav`, `mp3`, + `flac`, + + `opus`, or `pcm16`. presence_penalty: type: number default: 0 @@ -12142,28 +12305,34 @@ components: group: chat example: | { - "id": "chatcmpl-123", + "id": "chatcmpl-123456", "object": "chat.completion", - "created": 1677652288, - "model": "gpt-4o-mini", - "system_fingerprint": "fp_44709d6fcb", - "choices": [{ - "index": 0, - "message": { - "role": "assistant", - "content": "\n\nHello there, how may I assist you today?", - }, - "logprobs": null, - "finish_reason": "stop" - }], + "created": 1728933352, + "model": "gpt-4o-2024-08-06", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "Hi there! How can I assist you today?", + "refusal": null + }, + "logprobs": null, + "finish_reason": "stop" + } + ], "usage": { - "prompt_tokens": 9, - "completion_tokens": 12, - "total_tokens": 21, + "prompt_tokens": 19, + "completion_tokens": 10, + "total_tokens": 29, + "prompt_tokens_details": { + "cached_tokens": 0 + }, "completion_tokens_details": { "reasoning_tokens": 0 } - } + }, + "system_fingerprint": "fp_6b68a8204b" } CreateChatCompletionStreamResponse: type: object @@ -12268,6 +12437,7 @@ components: - chat.completion.chunk usage: type: object + nullable: true description: > An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request. @@ -17273,65 +17443,32 @@ components: - role RealtimeClientEventConversationItemCreate: type: object - description: Send this event when adding an item to the conversation. + description: >- + Add a new Item to the Conversation's context, including messages, + function calls, and function call responses. This event can be used both + to populate a "history" of the conversation and to add new items + mid-stream, but has the current limitation that it cannot populate + assistant audio messages. + + If successful, the server will respond with a + `conversation.item.created` event, otherwise an `error` event will be + sent. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string - description: The event type, must be "conversation.item.create". + description: The event type, must be `conversation.item.create`. previous_item_id: type: string description: The ID of the preceding item after which the new item will be - inserted. + inserted. If not set, the new item will be appended to the end of + the conversation. If set, it allows an item to be inserted + mid-conversation. If the ID cannot be found, an error will be + returned and the item will not be added. item: - type: object - description: The item to add to the conversation. - properties: - id: - type: string - description: The unique ID of the item. - type: - type: string - description: The type of the item ("message", "function_call", - "function_call_output"). - status: - type: string - description: The status of the item ("completed", "in_progress", "incomplete"). - role: - type: string - description: The role of the message sender ("user", "assistant", "system"). - content: - type: array - description: The content of the message. - items: - type: object - properties: - type: - type: string - description: The content type ("input_text", "input_audio", "text", "audio"). - text: - type: string - description: The text content. - audio: - type: string - description: Base64-encoded audio bytes. - transcript: - type: string - description: The transcript of the audio. - call_id: - type: string - description: The ID of the function call (for "function_call" items). - name: - type: string - description: The name of the function being called (for "function_call" items). - arguments: - type: string - description: The arguments of the function call (for "function_call" items). - output: - type: string - description: The output of the function call (for "function_call_output" items). + $ref: "#/components/schemas/RealtimeConversationItem" required: - type - item @@ -17346,7 +17483,6 @@ components: "item": { "id": "msg_001", "type": "message", - "status": "completed", "role": "user", "content": [ { @@ -17359,7 +17495,10 @@ components: RealtimeClientEventConversationItemDelete: type: object description: Send this event when you want to remove any item from the - conversation history. + conversation history. The server will respond with a + `conversation.item.deleted` event, unless the item does not exist in the + conversation history, in which case the server will respond with an + error. properties: event_id: type: string @@ -17384,8 +17523,18 @@ components: } RealtimeClientEventConversationItemTruncate: type: object - description: Send this event when you want to truncate a previous assistant - message’s audio. + description: >- + Send this event to truncate a previous assistant message’s audio. The + server will produce audio faster than realtime, so this event is useful + when the user interrupts to truncate audio that has already been sent to + the client but not yet played. This will synchronize the server's + understanding of the audio with the client's playback. + + Truncating audio will delete the server-side text transcript to ensure + there is not text in the context that hasn't been heard by the user. + + If successful, the server will respond with a + `conversation.item.truncated` event. properties: event_id: type: string @@ -17395,13 +17544,16 @@ components: description: The event type, must be "conversation.item.truncate". item_id: type: string - description: The ID of the assistant message item to truncate. + description: The ID of the assistant message item to truncate. Only assistant + message items can be truncated. content_index: type: integer - description: The index of the content part to truncate. + description: The index of the content part to truncate. Set this to 0. audio_end_ms: type: integer description: Inclusive duration up to which audio is truncated, in milliseconds. + If the audio_end_ms is greater than the actual audio duration, the + server will respond with an error. required: - type - item_id @@ -17420,7 +17572,17 @@ components: } RealtimeClientEventInputAudioBufferAppend: type: object - description: Send this event to append audio bytes to the input audio buffer. + description: >- + Send this event to append audio bytes to the input audio buffer. The + audio buffer is temporary storage you can write to and later commit. In + Server VAD mode, the audio buffer is used to detect speech and the + server will decide when to commit. When Server VAD is disabled, you must + commit the audio buffer manually. + + The client may choose how much audio to place in each event up to a + maximum of 15 MiB, for example streaming smaller chunks from the client + may allow the VAD to be more responsive. Unlike made other client + events, the server will not send a confirmation response to this event. properties: event_id: type: string @@ -17430,7 +17592,8 @@ components: description: The event type, must be "input_audio_buffer.append". audio: type: string - description: Base64-encoded audio bytes. + description: Base64-encoded audio bytes. This must be in the format specified by + the `input_audio_format` field in the session configuration. required: - type - audio @@ -17445,7 +17608,8 @@ components: } RealtimeClientEventInputAudioBufferClear: type: object - description: Send this event to clear the audio bytes in the buffer. + description: Send this event to clear the audio bytes in the buffer. The server + will respond with an `input_audio_buffer.cleared` event. properties: event_id: type: string @@ -17465,7 +17629,17 @@ components: } RealtimeClientEventInputAudioBufferCommit: type: object - description: Send this event to commit audio bytes to a user message. + description: >- + Send this event to commit the user input audio buffer, which will create + a new user message item in the conversation. This event will produce an + error if the input audio buffer is empty. When in Server VAD mode, the + client does not need to send this event, the server will commit the + audio buffer automatically. + + Committing the input audio buffer will trigger input audio transcription + (if enabled in session configuration), but it will not create a response + from the model. The server will respond with an + `input_audio_buffer.committed` event. properties: event_id: type: string @@ -17485,14 +17659,16 @@ components: } RealtimeClientEventResponseCancel: type: object - description: Send this event to cancel an in-progress response. + description: Send this event to cancel an in-progress response. The server will + respond with a `response.cancelled` event or an error if there is no + response to cancel. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string - description: The event type, must be "response.cancel". + description: The event type, must be `response.cancel`. required: - type x-oaiMeta: @@ -17505,67 +17681,31 @@ components: } RealtimeClientEventResponseCreate: type: object - description: Send this event to trigger a response generation. + description: >- + This event instructs the server to create a Response, which means + triggering model inference. When in Server VAD mode, the server will + create Responses automatically. + + A Response will include at least one Item, and may have two, in which + case the second will be a function call. These Items will be appended to + the conversation history. + + The server will respond with a `response.created` event, events for + Items and content created, and finally a `response.done` event to + indicate the Response is complete. + + The `response.create` event includes inference configuration like + `instructions`, and `temperature`. These fields will override the + Session's configuration for this Response only. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string - description: The event type, must be "response.create". + description: The event type, must be `response.create`. response: - type: object - description: Configuration for the response. - properties: - modalities: - type: array - items: - type: string - description: The modalities for the response. - instructions: - type: string - description: Instructions for the model. - voice: - type: string - description: The voice the model uses to respond - one of `alloy`, `echo`, or - `shimmer`. - output_audio_format: - type: string - description: The format of output audio. - tools: - type: array - description: Tools (functions) available to the model. - items: - type: object - properties: - type: - type: string - description: The type of the tool. - name: - type: string - description: The name of the function. - description: - type: string - description: The description of the function. - parameters: - type: object - description: Parameters of the function in JSON Schema. - tool_choice: - type: string - description: How the model chooses tools. - temperature: - type: number - description: Sampling temperature. - max_output_tokens: - oneOf: - - type: integer - - type: string - enum: - - inf - description: Maximum number of output tokens for a single assistant response, - inclusive of tool calls. Provide an integer between 1 and 4096 - to limit output tokens, or "inf" for the maximum available - tokens for a given model. Defaults to "inf". + $ref: "#/components/schemas/RealtimeResponse" required: - type - response @@ -17603,7 +17743,13 @@ components: } RealtimeClientEventSessionUpdate: type: object - description: Send this event to update the session’s default configuration. + description: Send this event to update the session’s default configuration. The + client may send this event at any time to update the session + configuration, and any field may be updated at any time, except for + "voice". The server will respond with a `session.updated` event that + shows the full effective configuration. Only fields that are present are + updated, thus the correct way to clear a field like "instructions" is to + pass an empty string. properties: event_id: type: string @@ -17612,90 +17758,7 @@ components: type: string description: The event type, must be "session.update". session: - type: object - description: Session configuration to update. - properties: - modalities: - type: array - items: - type: string - description: The set of modalities the model can respond with. To disable audio, - set this to ["text"]. - instructions: - type: string - description: The default system instructions prepended to model calls. - voice: - type: string - description: The voice the model uses to respond - one of `alloy`, `echo`, - or `shimmer`. Cannot be changed once the model has responded - with audio at least once. - input_audio_format: - type: string - description: The format of input audio. Options are "pcm16", "g711_ulaw", or - "g711_alaw". - output_audio_format: - type: string - description: The format of output audio. Options are "pcm16", "g711_ulaw", or - "g711_alaw". - input_audio_transcription: - type: object - description: Configuration for input audio transcription. Can be set to `null` - to turn off. - properties: - model: - type: string - description: The model to use for transcription (e.g., "whisper-1"). - turn_detection: - type: object - description: Configuration for turn detection. Can be set to `null` to turn off. - properties: - type: - type: string - description: Type of turn detection, only "server_vad" is currently supported. - threshold: - type: number - description: Activation threshold for VAD (0.0 to 1.0). - prefix_padding_ms: - type: integer - description: Amount of audio to include before speech starts (in milliseconds). - silence_duration_ms: - type: integer - description: Duration of silence to detect speech stop (in milliseconds). - tools: - type: array - description: Tools (functions) available to the model. - items: - type: object - properties: - type: - type: string - description: The type of the tool, e.g., "function". - name: - type: string - description: The name of the function. - description: - type: string - description: The description of the function. - parameters: - type: object - description: Parameters of the function in JSON Schema. - tool_choice: - type: string - description: How the model chooses tools. Options are "auto", "none", - "required", or specify a function. - temperature: - type: number - description: Sampling temperature for the model. - max_output_tokens: - oneOf: - - type: integer - - type: string - enum: - - inf - description: Maximum number of output tokens for a single assistant response, - inclusive of tool calls. Provide an integer between 1 and 4096 - to limit output tokens, or "inf" for the maximum available - tokens for a given model. Defaults to "inf". + $ref: "#/components/schemas/RealtimeSession" required: - type - session @@ -17719,13 +17782,13 @@ components: "type": "server_vad", "threshold": 0.5, "prefix_padding_ms": 300, - "silence_duration_ms": 200 + "silence_duration_ms": 500 }, "tools": [ { "type": "function", "name": "get_weather", - "description": "Get the current weather for a location.", + "description": "Get the current weather for a location, tell the user you are fetching the weather.", "parameters": { "type": "object", "properties": { @@ -17737,9 +17800,157 @@ components: ], "tool_choice": "auto", "temperature": 0.8, - "max_output_tokens": null + "max_response_output_tokens": "inf" } } + RealtimeConversationItem: + type: object + description: The item to add to the conversation. + properties: + id: + type: string + description: The unique ID of the item, this can be generated by the client to + help manage server-side context, but is not required because the + server will generate one if not provided. + type: + type: string + description: The type of the item (`message`, `function_call`, + `function_call_output`). + status: + type: string + description: The status of the item (`completed`, `incomplete`). These have no + effect on the conversation, but are accepted for consistency with + the `conversation.item.created` event. + role: + type: string + description: The role of the message sender (`user`, `assistant`, `system`), + only applicable for `message` items. + content: + type: array + description: The content of the message, applicable for `message` items. Message + items with a role of `system` support only `input_text` content, + message items of role `user` support `input_text` and `input_audio` + content, and message items of role `assistant` support `text` + content. + items: + type: object + properties: + type: + type: string + description: The content type (`input_text`, `input_audio`, `text`). + text: + type: string + description: The text content, used for `input_text` and `text` content types. + audio: + type: string + description: Base64-encoded audio bytes, used for `input_audio` content type. + transcript: + type: string + description: The transcript of the audio, used for `input_audio` content type. + call_id: + type: string + description: The ID of the function call (for `function_call` and + `function_call_output` items). If passed on a `function_call_output` + item, the server will check that a `function_call` item with the + same ID exists in the conversation history. + name: + type: string + description: The name of the function being called (for `function_call` items). + arguments: + type: string + description: The arguments of the function call (for `function_call` items). + output: + type: string + description: The output of the function call (for `function_call_output` items). + RealtimeResponse: + type: object + description: The response resource. + properties: + id: + type: string + description: The unique ID of the response. + object: + type: string + description: The object type, must be `realtime.response`. + status: + type: string + description: The final status of the response (`completed`, `cancelled`, + `failed`, `incomplete`). + status_details: + type: object + description: Additional details about the status. + properties: + type: + type: string + description: The type of error that caused the response to fail, corresponding + with the `status` field (`cancelled`, `incomplete`, `failed`). + reason: + type: string + description: The reason the Response did not complete. For a `cancelled` + Response, one of `turn_detected` (the server VAD detected a new + start of speech) or `client_cancelled` (the client sent a cancel + event). For an `incomplete` Response, one of `max_output_tokens` + or `content_filter` (the server-side safety filter activated and + cut off the response). + error: + type: object + description: A description of the error that caused the response to fail, + populated when the `status` is `failed`. + properties: + type: + type: string + description: The type of error. + code: + type: string + description: Error code, if any. + output: + type: array + description: The list of output items generated by the response. + items: + type: object + description: An item in the response output. + usage: + type: object + description: Usage statistics for the Response, this will correspond to billing. + A Realtime API session will maintain a conversation context and + append new Items to the Conversation, thus output from previous + turns (text and audio tokens) will become the input for later turns. + properties: + total_tokens: + type: integer + description: The total number of tokens in the Response including input and + output text and audio tokens. + input_tokens: + type: integer + description: The number of input tokens used in the Response, including text and + audio tokens. + output_tokens: + type: integer + description: The number of output tokens sent in the Response, including text + and audio tokens. + input_token_details: + type: object + description: Details about the input tokens used in the Response. + properties: + cached_tokens: + type: integer + description: The number of cached tokens used in the Response. + text_tokens: + type: integer + description: The number of text tokens used in the Response. + audio_tokens: + type: integer + description: The number of audio tokens used in the Response. + output_token_details: + type: object + description: Details about the output tokens used in the Response. + properties: + text_tokens: + type: integer + description: The number of text tokens used in the Response. + audio_tokens: + type: integer + description: The number of audio tokens used in the Response. RealtimeServerEventConversationCreated: type: object description: Returned when a conversation is created. Emitted right after @@ -17779,67 +17990,25 @@ components: } RealtimeServerEventConversationItemCreated: type: object - description: Returned when a conversation item is created. + description: >- + Returned when a conversation item is created. There are several + scenarios that produce this event: + - The server is generating a Response, which if successful will produce either one or two Items, which will be of type `message` (role `assistant`) or type `function_call`. + - The input audio buffer has been committed, either by the client or the server (in `server_vad` mode). The server will take the content of the input audio buffer and add it to a new user message Item. + - The client has sent a `conversation.item.create` event to add a new Item to the Conversation. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "conversation.item.created". + description: The event type, must be `conversation.item.created`. previous_item_id: type: string - description: The ID of the preceding item. + description: The ID of the preceding item in the Conversation context, allows + the client to understand the order of the conversation. item: - type: object - description: The item that was created. - properties: - id: - type: string - description: The unique ID of the item. - object: - type: string - description: The object type, must be "realtime.item". - type: - type: string - description: The type of the item ("message", "function_call", - "function_call_output"). - status: - type: string - description: The status of the item ("completed", "in_progress", "incomplete"). - role: - type: string - description: The role associated with the item ("user", "assistant", "system"). - content: - type: array - description: The content of the item. - items: - type: object - properties: - type: - type: string - description: The content type ("text", "audio", "input_text", "input_audio"). - text: - type: string - description: The text content. - audio: - type: string - description: Base64-encoded audio data. - transcript: - type: string - description: The transcript of the audio. - call_id: - type: string - description: The ID of the function call (for "function_call" items). - name: - type: string - description: The name of the function being called. - arguments: - type: string - description: The arguments of the function call. - output: - type: string - description: The output of the function call (for "function_call_output" items). + $ref: "#/components/schemas/RealtimeConversationItem" required: - event_id - type @@ -17862,21 +18031,25 @@ components: "content": [ { "type": "input_audio", - "transcript": null + "transcript": "hello how are you", + "audio": "base64encodedaudio==" } ] } } RealtimeServerEventConversationItemDeleted: type: object - description: Returned when an item in the conversation is deleted. + description: Returned when an item in the conversation is deleted by the client + with a `conversation.item.delete` event. This event is used to + synchronize the server's understanding of the conversation history with + the client's view. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "conversation.item.deleted". + description: The event type, must be `conversation.item.deleted`. item_id: type: string description: The ID of the item that was deleted. @@ -17895,8 +18068,18 @@ components: } RealtimeServerEventConversationItemInputAudioTranscriptionCompleted: type: object - description: Returned when input audio transcription is enabled and a - transcription succeeds. + description: >- + This event is the output of audio transcription for user audio written + to the user audio buffer. Transcription begins when the input audio + buffer is committed by the client or server (in `server_vad` mode). + Transcription runs asynchronously with Response creation, so this event + may come before or after the Response events. + + Realtime API models accept audio natively, and thus input transcription + is a separate process run on a separate ASR (Automatic Speech + Recognition) model, currently always `whisper-1`. Thus the transcript + may diverge somewhat from the model's interpretation, and should be + treated as a rough guide. properties: event_id: type: string @@ -17904,10 +18087,10 @@ components: type: type: string description: The event type, must be - "conversation.item.input_audio_transcription.completed". + `conversation.item.input_audio_transcription.completed`. item_id: type: string - description: The ID of the user message item. + description: The ID of the user message item containing the audio. content_index: type: integer description: The index of the content part containing the audio. @@ -17934,7 +18117,9 @@ components: RealtimeServerEventConversationItemInputAudioTranscriptionFailed: type: object description: Returned when input audio transcription is configured, and a - transcription request for a user message failed. + transcription request for a user message failed. These events are + separate from other `error` events so that the client can identify the + related Item. properties: event_id: type: string @@ -17942,7 +18127,7 @@ components: type: type: string description: The event type, must be - "conversation.item.input_audio_transcription.failed". + `conversation.item.input_audio_transcription.failed`. item_id: type: string description: The ID of the user message item. @@ -17989,15 +18174,22 @@ components: } RealtimeServerEventConversationItemTruncated: type: object - description: Returned when an earlier assistant audio message item is truncated - by the client. + description: >- + Returned when an earlier assistant audio message item is truncated by + the client with a `conversation.item.truncate` event. This event is used + to synchronize the server's understanding of the audio with the client's + playback. + + This action will truncate the audio and remove the server-side text + transcript to ensure there is no text in the context that hasn't been + heard by the user. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "conversation.item.truncated". + description: The event type, must be `conversation.item.truncated`. item_id: type: string description: The ID of the assistant message item that was truncated. @@ -18026,7 +18218,10 @@ components: } RealtimeServerEventError: type: object - description: Returned when an error occurs. + description: Returned when an error occurs, which could be a client problem or a + server problem. Most errors are recoverable and the session will stay + open, we recommend to implementors to monitor and log error messages by + default. properties: event_id: type: string @@ -18075,14 +18270,15 @@ components: } RealtimeServerEventInputAudioBufferCleared: type: object - description: Returned when the input audio buffer is cleared by the client. + description: Returned when the input audio buffer is cleared by the client with + a `input_audio_buffer.clear` event. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "input_audio_buffer.cleared". + description: The event type, must be `input_audio_buffer.cleared`. required: - event_id - type @@ -18097,14 +18293,16 @@ components: RealtimeServerEventInputAudioBufferCommitted: type: object description: Returned when an input audio buffer is committed, either by the - client or automatically in server VAD mode. + client or automatically in server VAD mode. The `item_id` property is + the ID of the user message item that will be created, thus a + `conversation.item.created` event will also be sent to the client. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "input_audio_buffer.committed". + description: The event type, must be `input_audio_buffer.committed`. previous_item_id: type: string description: The ID of the preceding item after which the new item will be @@ -18129,17 +18327,29 @@ components: } RealtimeServerEventInputAudioBufferSpeechStarted: type: object - description: Returned in server turn detection mode when speech is detected. + description: Sent by the server when in `server_vad` mode to indicate that + speech has been detected in the audio buffer. This can happen any time + audio is added to the buffer (unless speech is already detected). The + client may want to use this event to interrupt audio playback or provide + visual feedback to the user. The client should expect to receive a + `input_audio_buffer.speech_stopped` event when speech stops. The + `item_id` property is the ID of the user message item that will be + created when speech stops and will also be included in the + `input_audio_buffer.speech_stopped` event (unless the client manually + commits the audio buffer during VAD activation). properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "input_audio_buffer.speech_started". + description: The event type, must be `input_audio_buffer.speech_started`. audio_start_ms: type: integer - description: Milliseconds since the session started when speech was detected. + description: Milliseconds from the start of all audio written to the buffer + during the session when speech was first detected. This will + correspond to the beginning of audio sent to the model, and thus + includes the `prefix_padding_ms` configured in the Session. item_id: type: string description: The ID of the user message item that will be created when speech @@ -18161,17 +18371,22 @@ components: } RealtimeServerEventInputAudioBufferSpeechStopped: type: object - description: Returned in server turn detection mode when speech stops. + description: Returned in `server_vad` mode when the server detects the end of + speech in the audio buffer. The server will also send an + `conversation.item.created` event with the user message item that is + created from the audio buffer. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "input_audio_buffer.speech_stopped". + description: The event type, must be `input_audio_buffer.speech_stopped`. audio_end_ms: type: integer - description: Milliseconds since the session started when speech stopped. + description: Milliseconds since the session started when speech stopped. This + will correspond to the end of audio sent to the model, and thus + includes the `min_silence_duration_ms` configured in the Session. item_id: type: string description: The ID of the user message item that will be created. @@ -18192,15 +18407,17 @@ components: } RealtimeServerEventRateLimitsUpdated: type: object - description: Emitted after every "response.done" event to indicate the updated - rate limits. + description: Emitted at the beginning of a Response to indicate the updated rate + limits. When a Response is created some tokens will be "reserved" for + the output tokens, the rate limits shown here reflect that reservation, + which is then adjusted accordingly once the Response is completed. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "rate_limits.updated". + description: The event type, must be `rate_limits.updated`. rate_limits: type: array description: List of rate limit information. @@ -18209,8 +18426,7 @@ components: properties: name: type: string - description: The name of the rate limit ("requests", "tokens", "input_tokens", - "output_tokens"). + description: The name of the rate limit (`requests`, `tokens`). limit: type: integer description: The maximum allowed value for the rate limit. @@ -18560,39 +18776,16 @@ components: type: object description: Returned when a new Response is created. The first event of response creation, where the response is in an initial state of - "in_progress". + `in_progress`. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.created". + description: The event type, must be `response.created`. response: - type: object - description: The response resource. - properties: - id: - type: string - description: The unique ID of the response. - object: - type: string - description: The object type, must be "realtime.response". - status: - type: string - description: The status of the response ("in_progress"). - status_details: - type: object - description: Additional details about the status. - output: - type: array - description: The list of output items generated by the response. - items: - type: object - description: An item in the response output. - usage: - type: object - description: Usage statistics for the response. + $ref: "#/components/schemas/RealtimeResponse" required: - event_id - type @@ -18616,7 +18809,9 @@ components: RealtimeServerEventResponseDone: type: object description: Returned when a Response is done streaming. Always emitted, no - matter the final state. + matter the final state. The Response object included in the + `response.done` event will include all output Items in the Response but + will omit the raw audio data. properties: event_id: type: string @@ -18625,31 +18820,7 @@ components: type: string description: The event type, must be "response.done". response: - type: object - description: The response resource. - properties: - id: - type: string - description: The unique ID of the response. - object: - type: string - description: The object type, must be "realtime.response". - status: - type: string - description: The final status of the response ("completed", "cancelled", - "failed", "incomplete"). - status_details: - type: object - description: Additional details about the status. - output: - type: array - description: The list of output items generated by the response. - items: - type: object - description: An item in the response output. - usage: - type: object - description: Usage statistics for the response. + $ref: "#/components/schemas/RealtimeResponse" required: - event_id - type @@ -18682,9 +18853,18 @@ components: } ], "usage": { - "total_tokens": 50, - "input_tokens": 20, - "output_tokens": 30 + "total_tokens":275, + "input_tokens":127, + "output_tokens":148, + "input_token_details": { + "cached_tokens":0, + "text_tokens":119, + "audio_tokens":8 + }, + "output_token_details": { + "text_tokens":36, + "audio_tokens":112 + } } } } @@ -18784,58 +18964,22 @@ components: } RealtimeServerEventResponseOutputItemAdded: type: object - description: Returned when a new Item is created during response generation. + description: Returned when a new Item is created during Response generation. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.output_item.added". + description: The event type, must be `response.output_item.added`. response_id: type: string - description: The ID of the response to which the item belongs. + description: The ID of the Response to which the item belongs. output_index: type: integer - description: The index of the output item in the response. + description: The index of the output item in the Response. item: - type: object - description: The item that was added. - properties: - id: - type: string - description: The unique ID of the item. - object: - type: string - description: The object type, must be "realtime.item". - type: - type: string - description: The type of the item ("message", "function_call", - "function_call_output"). - status: - type: string - description: The status of the item ("in_progress", "completed"). - role: - type: string - description: The role associated with the item ("assistant"). - content: - type: array - description: The content of the item. - items: - type: object - properties: - type: - type: string - description: The content type ("text", "audio"). - text: - type: string - description: The text content. - audio: - type: string - description: Base64-encoded audio data. - transcript: - type: string - description: The transcript of the audio. + $ref: "#/components/schemas/RealtimeConversationItem" required: - event_id - type @@ -18870,51 +19014,15 @@ components: description: The unique ID of the server event. type: type: string - description: The event type, must be "response.output_item.done". + description: The event type, must be `response.output_item.done`. response_id: type: string - description: The ID of the response to which the item belongs. + description: The ID of the Response to which the item belongs. output_index: type: integer - description: The index of the output item in the response. + description: The index of the output item in the Response. item: - type: object - description: The completed item. - properties: - id: - type: string - description: The unique ID of the item. - object: - type: string - description: The object type, must be "realtime.item". - type: - type: string - description: The type of the item ("message", "function_call", - "function_call_output"). - status: - type: string - description: The final status of the item ("completed", "incomplete"). - role: - type: string - description: The role associated with the item ("assistant"). - content: - type: array - description: The content of the item. - items: - type: object - properties: - type: - type: string - description: The content type ("text", "audio"). - text: - type: string - description: The text content. - audio: - type: string - description: Base64-encoded audio data. - transcript: - type: string - description: The transcript of the audio. + $ref: "#/components/schemas/RealtimeConversationItem" required: - event_id - type @@ -19040,103 +19148,18 @@ components: } RealtimeServerEventSessionCreated: type: object - description: Returned when a session is created. Emitted automatically when a - new connection is established. + description: Returned when a Session is created. Emitted automatically when a + new connection is established as the first server event. This event will + contain the default Session configuration. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "session.created". + description: The event type, must be `session.created`. session: - type: object - description: The session resource. - properties: - id: - type: string - description: The unique ID of the session. - object: - type: string - description: The object type, must be "realtime.session". - model: - type: string - description: The default model used for this session. - modalities: - type: array - items: - type: string - description: The set of modalities the model can respond with. - instructions: - type: string - description: The default system instructions. - voice: - type: string - description: The voice the model uses to respond - one of `alloy`, `echo`, or - `shimmer`. - input_audio_format: - type: string - description: The format of input audio. - output_audio_format: - type: string - description: The format of output audio. - input_audio_transcription: - type: object - description: Configuration for input audio transcription. - properties: - enabled: - type: boolean - description: Whether input audio transcription is enabled. - model: - type: string - description: The model used for transcription. - turn_detection: - type: object - description: Configuration for turn detection. - properties: - type: - type: string - description: The type of turn detection ("server_vad" or "none"). - threshold: - type: number - description: Activation threshold for VAD. - prefix_padding_ms: - type: integer - description: Audio included before speech starts (in milliseconds). - silence_duration_ms: - type: integer - description: Duration of silence to detect speech stop (in milliseconds). - tools: - type: array - description: Tools (functions) available to the model. - items: - type: object - properties: - type: - type: string - description: The type of the tool. - name: - type: string - description: The name of the function. - description: - type: string - description: The description of the function. - parameters: - type: object - description: Parameters of the function in JSON Schema. - tool_choice: - type: string - description: How the model chooses tools. - temperature: - type: number - description: Sampling temperature. - max_output_tokens: - oneOf: - - type: integer - - type: string - enum: - - inf - description: Maximum number of output tokens. + $ref: "#/components/schemas/RealtimeSession" required: - event_id - type @@ -19167,12 +19190,13 @@ components: "tools": [], "tool_choice": "auto", "temperature": 0.8, - "max_output_tokens": null + "max_response_output_tokens": null } } RealtimeServerEventSessionUpdated: type: object - description: Returned when a session is updated. + description: Returned when a session is updated with a `session.update` event, + unless there is an error. properties: event_id: type: string @@ -19181,93 +19205,7 @@ components: type: string description: The event type, must be "session.updated". session: - type: object - description: The updated session resource. - properties: - id: - type: string - description: The unique ID of the session. - object: - type: string - description: The object type, must be "realtime.session". - model: - type: string - description: The default model used for this session. - modalities: - type: array - items: - type: string - description: The set of modalities the model can respond with. - instructions: - type: string - description: The default system instructions. - voice: - type: string - description: The voice the model uses to respond - one of `alloy`, `echo`, or - `shimmer`. - input_audio_format: - type: string - description: The format of input audio. - output_audio_format: - type: string - description: The format of output audio. - input_audio_transcription: - type: object - description: Configuration for input audio transcription. - properties: - enabled: - type: boolean - description: Whether input audio transcription is enabled. - model: - type: string - description: The model used for transcription. - turn_detection: - type: object - description: Configuration for turn detection. - properties: - type: - type: string - description: The type of turn detection ("server_vad" or "none"). - threshold: - type: number - description: Activation threshold for VAD. - prefix_padding_ms: - type: integer - description: Audio included before speech starts (in milliseconds). - silence_duration_ms: - type: integer - description: Duration of silence to detect speech stop (in milliseconds). - tools: - type: array - description: Tools (functions) available to the model. - items: - type: object - properties: - type: - type: string - description: The type of the tool. - name: - type: string - description: The name of the function. - description: - type: string - description: The description of the function. - parameters: - type: object - description: Parameters of the function in JSON Schema. - tool_choice: - type: string - description: How the model chooses tools. - temperature: - type: number - description: Sampling temperature. - max_output_tokens: - oneOf: - - type: integer - - type: string - enum: - - inf - description: Maximum number of output tokens. + $ref: "#/components/schemas/RealtimeSession" required: - event_id - type @@ -19289,18 +19227,127 @@ components: "input_audio_format": "pcm16", "output_audio_format": "pcm16", "input_audio_transcription": { - "enabled": true, "model": "whisper-1" }, - "turn_detection": { - "type": "none" - }, + "turn_detection": null, "tools": [], "tool_choice": "none", "temperature": 0.7, - "max_output_tokens": 200 + "max_response_output_tokens": 200 } } + RealtimeSession: + type: object + description: Realtime session object configuration. + properties: + modalities: + type: array + items: + type: string + description: The set of modalities the model can respond with. To disable audio, + set this to ["text"]. + instructions: + type: string + description: >- + The default system instructions (i.e. system message) prepended to + model calls. This field allows the client to guide the model on + desired responses. The model can be instructed on response content + and format, (e.g. "be extremely succinct", "act friendly", "here are + examples of good responses") and on audio behavior (e.g. "talk + quickly", "inject emotion into your voice", "laugh frequently"). The + instructions are not guaranteed to be followed by the model, but + they provide guidance to the model on the desired behavior. + + Note that the server sets default instructions which will be used if + this field is not set and are visible in the `session.created` event + at the start of the session. + voice: + type: string + description: The voice the model uses to respond - one of `alloy`, `echo`, + or `shimmer`. Cannot be changed once the model has responded with + audio at least once. + input_audio_format: + type: string + description: The format of input audio. Options are `pcm16`, `g711_ulaw`, or + `g711_alaw`. + output_audio_format: + type: string + description: The format of output audio. Options are `pcm16`, `g711_ulaw`, or + `g711_alaw`. + input_audio_transcription: + type: object + description: Configuration for input audio transcription, defaults to off and + can be set to `null` to turn off once on. Input audio transcription + is not native to the model, since the model consumes audio directly. + Transcription runs asynchronously through Whisper and should be + treated as rough guidance rather than the representation understood + by the model. + properties: + model: + type: string + description: The model to use for transcription, `whisper-1` is the only + currently supported model. + turn_detection: + type: object + description: Configuration for turn detection. Can be set to `null` to turn off. + Server VAD means that the model will detect the start and end of + speech based on audio volume and respond at the end of user speech. + properties: + type: + type: string + description: Type of turn detection, only `server_vad` is currently supported. + threshold: + type: number + description: Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A + higher threshold will require louder audio to activate the + model, and thus might perform better in noisy environments. + prefix_padding_ms: + type: integer + description: Amount of audio to include before the VAD detected speech (in + milliseconds). Defaults to 300ms. + silence_duration_ms: + type: integer + description: Duration of silence to detect speech stop (in milliseconds). + Defaults to 500ms. With shorter values the model will respond + more quickly, but may jump in on short pauses from the user. + tools: + type: array + description: Tools (functions) available to the model. + items: + type: object + properties: + type: + type: string + description: The type of the tool, i.e. `function`. + name: + type: string + description: The name of the function. + description: + type: string + description: The description of the function, including guidance on when and how + to call it, and guidance about what to tell the user when + calling (if anything). + parameters: + type: object + description: Parameters of the function in JSON Schema. + tool_choice: + type: string + description: How the model chooses tools. Options are `auto`, `none`, + `required`, or specify a function. + temperature: + type: number + description: Sampling temperature for the model, limited to [0.6, 1.2]. Defaults + to 0.8. + max_response_output_tokens: + oneOf: + - type: integer + - type: string + enum: + - inf + description: Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. ResponseFormatJsonObject: type: object properties: From f1148f606ad3a7ac8a0370e9c44afcb66e23d596 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Tue, 7 Jan 2025 12:04:04 -0800 Subject: [PATCH 03/44] post-merge regen of API, should diff more cleanly now --- .dotnet/api/OpenAI.netstandard2.0.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index cc516238a..c57f4943a 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1150,17 +1150,8 @@ public class ChatAudioOptions : IJsonModel, IPersistableModel< public ChatAudioOptions(ChatResponseVoice responseVoice, ChatOutputAudioFormat outputAudioFormat); public ChatOutputAudioFormat OutputAudioFormat { get; set; } public ChatResponseVoice ResponseVoice { get; set; } - protected virtual ChatAudioOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options); - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options); public static explicit operator ChatAudioOptions(ClientResult result); public static implicit operator BinaryContent(ChatAudioOptions chatAudioOptions); - protected virtual ChatAudioOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options); - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options); - ChatAudioOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options); - ChatAudioOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options); - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options); } public class ChatClient { protected ChatClient(); @@ -1274,8 +1265,6 @@ public class ChatFunctionChoice : IJsonModel, IPersistableMo public override readonly string ToString(); } public readonly partial struct ChatInputAudioFormat : IEquatable { - private readonly object _dummy; - private readonly int _dummyPrimitive; public ChatInputAudioFormat(string value); public static ChatInputAudioFormat Mp3 { get; } public static ChatInputAudioFormat Wav { get; } @@ -1361,8 +1350,6 @@ public enum ChatMessageRole { Function = 4 } public readonly partial struct ChatOutputAudioFormat : IEquatable { - private readonly object _dummy; - private readonly int _dummyPrimitive; public ChatOutputAudioFormat(string value); public static ChatOutputAudioFormat Flac { get; } public static ChatOutputAudioFormat Mp3 { get; } @@ -1393,8 +1380,6 @@ public class ChatResponseFormat : IJsonModel, IPersistableMo public static implicit operator BinaryContent(ChatResponseFormat chatResponseFormat); } public readonly partial struct ChatResponseVoice : IEquatable { - private readonly object _dummy; - private readonly int _dummyPrimitive; public ChatResponseVoice(string value); public static ChatResponseVoice Alloy { get; } public static ChatResponseVoice Echo { get; } From 388632598c33c3bff695a0a3911a6039e92b4e81 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Fri, 10 Jan 2025 12:11:31 -0800 Subject: [PATCH 04/44] retarget, retest, squish, disable unsupported things --- .../Azure.AI.OpenAI/Directory.Build.props | 2 +- .../sdk/openai/Azure.AI.OpenAI/assets.json | 2 +- .../src/Custom/AzureOpenAIClient.cs | 4 +- .../src/Custom/AzureOpenAIClientOptions.cs | 6 +- .../src/Custom/Chat/AzureChatExtensions.cs | 19 + .../src/Custom/Chat/UserSecurityContext.cs | 20 + .../ContentFilterTextSpan.Serialization.cs | 154 + .../src/Generated/ContentFilterTextSpan.cs | 74 + ...ntentFilterTextSpanResult.Serialization.cs | 175 + .../Generated/ContentFilterTextSpanResult.cs | 84 + ...sponseContentFilterResult.Serialization.cs | 16 + .../Generated/ResponseContentFilterResult.cs | 4 +- .../UserSecurityContext.Serialization.cs | 176 + .../src/Generated/UserSecurityContext.cs | 64 + .../tests/Assets/playback_test_config.json | 2 + .../Azure.AI.OpenAI/tests/AssistantTests.cs | 18 +- .../Azure.AI.OpenAI/tests/BatchTests.cs | 8 +- .../Azure.AI.OpenAI/tests/ChatTests.Audio.cs | 18 + .../Azure.AI.OpenAI/tests/ChatTests.Tools.cs | 2 +- .../openai/Azure.AI.OpenAI/tests/ChatTests.cs | 26 + .../tests/ConversationTestFixtureBase.cs | 1 + .../openai/Azure.AI.OpenAI/tests/FileTests.cs | 7 +- .../Azure.AI.OpenAI/tests/FineTuningTests.cs | 48 +- .../Azure.AI.OpenAI/tests/ImageTests.cs | 1 - .../tests/Utils/AoaiTestBase.cs | 24 +- .../Azure.AI.OpenAI/tests/VectorStoreTests.cs | 3 +- .../src/RecordedTestAttribute.cs | 3 +- .github/workflows/main.yml | 2 +- ...pi3-azure-openai-2024-06-01-generated.yaml | 1 + ...e-openai-2024-08-01-preview-generated.yaml | 1 + ...e-openai-2024-09-01-preview-generated.yaml | 1 + ...e-openai-2024-10-01-preview-generated.yaml | 1 + ...pi3-azure-openai-2024-10-21-generated.yaml | 1 + ...e-openai-2024-11-01-preview-generated.yaml | 3197 ++++++++++++++++ ...e-openai-2024-12-01-preview-generated.yaml | 3199 +++++++++++++++++ .typespec.azure/chat/models.request.tsp | 21 + .typespec.azure/common/models.rai.tsp | 3 + .typespec.azure/main.tsp | 5 + 38 files changed, 7317 insertions(+), 76 deletions(-) create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpan.Serialization.cs create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpan.cs create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpanResult.Serialization.cs create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpanResult.cs create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.Serialization.cs create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Audio.cs create mode 100644 .openapi3.azure/openapi3-azure-openai-2024-11-01-preview-generated.yaml create mode 100644 .openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/Directory.Build.props b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/Directory.Build.props index 2d3eea08f..6bc64d160 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/Directory.Build.props +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/Directory.Build.props @@ -4,8 +4,8 @@ $(RepoRoot)/../.dotnet/src/OpenAI.csproj - 2024_10_21 From file: {annotation.InputFileId}, replacement: {annotation.TextToReplace}"); + Assert.That(annotation.InputFileId, Is.Not.Null.And.Not.Empty); + Assert.That(annotation.TextToReplace, Is.Not.Null.And.Not.Empty); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs index 0999e43bc..15fb083c9 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs @@ -30,7 +30,12 @@ namespace Azure.AI.OpenAI.Tests; public class BatchTests : AoaiTestBase { public BatchTests(bool isAsync) : base(isAsync) - { } + { + if (new AzureOpenAIClientOptions().Version == "2024-12-01-preview") + { + Assert.Inconclusive("2024-12-01-preview not currently supported for files, fine-tuning, and related routes"); + } + } [Test] [Category("Smoke")] @@ -65,6 +70,7 @@ public async Task CanUploadFileForBatch() } [RecordedTest] + [Category("LongRunning")] // observed live runtime up to 5 minutes public async Task CanCancelBatch() { BatchClient batchClient = GetTestClient(); diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Audio.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Audio.cs new file mode 100644 index 000000000..562277fca --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Audio.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using Azure.AI.OpenAI.Chat; +using OpenAI.Chat; +using OpenAI.TestFramework; + +namespace Azure.AI.OpenAI.Tests +{ + public partial class ChatTests + { + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Tools.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Tools.cs index 535a599a0..35b46d7a5 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Tools.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Tools.cs @@ -60,7 +60,7 @@ public enum ToolChoiceTestType [TestCase(ToolChoiceTestType.None)] [TestCase(ToolChoiceTestType.Auto)] [TestCase(ToolChoiceTestType.Tool)] - [TestCase(ToolChoiceTestType.Required, Ignore = "This seems to be considered invalid")] + [TestCase(ToolChoiceTestType.Required)] public async Task SimpleToolWorks(ToolChoiceTestType toolChoice) { ChatClient client = GetTestClient(); diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs index 3f3d7486c..8016feb52 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs @@ -234,6 +234,7 @@ public async Task DefaultAzureCredentialWorks() [RecordedTest] [Ignore("Delay behavior not emulated by recordings, and needs to be run manually with some time in between iterations due to service throttling behavior")] + [Category("Live")] [TestCase("x-ms-retry-after-ms", "1000", 1000)] [TestCase("retry-after-ms", "1400", 1400)] [TestCase("Retry-After", "1", 1000)] @@ -516,6 +517,31 @@ public async Task StructuredOutputsWork() Assert.IsTrue(stepsProperty.ValueKind == JsonValueKind.Array); } + [RecordedTest] + public async Task UserSecurityContextWorks() + { + ChatClient client = GetTestClient(); + + string userId = Guid.NewGuid().ToString(); + string sourceIp = "123.456.78.9"; + UserSecurityContext userSecurityContext = new() + { + EndUserId = userId, + SourceIp = sourceIp, + }; + + ChatCompletionOptions options = new(); + options.SetUserSecurityContext(userSecurityContext); + + UserSecurityContext retrievedUserSecurityContext = options.GetUserSecurityContext(); + Assert.That(retrievedUserSecurityContext, Is.Not.Null); + Assert.That(retrievedUserSecurityContext.EndUserId, Is.EqualTo(userId)); + Assert.That(retrievedUserSecurityContext.SourceIp, Is.EqualTo(sourceIp)); + + ChatCompletion completion = await client.CompleteChatAsync([ChatMessage.CreateUserMessage("Hello, world!")]); + Assert.That(completion, Is.Not.Null); + } + #endregion #region Streaming chat completion tests diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs index d718cc1eb..971a38978 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs @@ -16,6 +16,7 @@ namespace Azure.AI.OpenAI.Tests; [Parallelizable(ParallelScope.All)] [Category("Conversation")] +[Category("Live")] public class ConversationTestFixtureBase { internal TestConfig TestConfig { get; } = new(() => RecordedTestMode.Live); diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs index 710405889..8818daa4a 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs @@ -11,7 +11,12 @@ namespace Azure.AI.OpenAI.Tests; public class FileTests : AoaiTestBase { public FileTests(bool isAsync) : base(isAsync) - { } + { + if (new AzureOpenAIClientOptions().Version == "2024-12-01-preview") + { + Assert.Inconclusive("2024-12-01-preview not currently supported for files, fine-tuning, and related routes"); + } + } [Test] [Category("Smoke")] diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs index ce12b8f82..c3f10cf15 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs @@ -29,9 +29,9 @@ public class FineTuningTests : AoaiTestBase { public FineTuningTests(bool isAsync) : base(isAsync) { - if (Mode == RecordedTestMode.Playback) + if (new AzureOpenAIClientOptions().Version == "2024-12-01-preview") { - Assert.Inconclusive("Playback for fine-tuning temporarily disabled"); + Assert.Inconclusive("2024-12-01-preview not currently supported for files, fine-tuning, and related routes"); } } @@ -145,24 +145,8 @@ public async Task CreateAndCancelFineTuning() FineTuningClient client = GetTestClient(); OpenAIFileClient fileClient = GetTestClientFrom(client); - OpenAIFile uploadedFile; - try - { - ClientResult fileResult = await fileClient.GetFileAsync("file-db5f5bfe5ea04ffcaeba89947a872828", new RequestOptions() { }); - uploadedFile = ValidateAndParse(fileResult); - } - catch (ClientResultException e) - { - if (e.Message.Contains("ResourceNotFound")) - { - // upload training data - uploadedFile = await UploadAndWaitForCompleteOrFail(fileClient, fineTuningFile.RelativePath); - } - else - { - throw; - } - } + OpenAIFile uploadedFile = await UploadAndWaitForCompleteOrFail(fileClient, fineTuningFile.RelativePath); + Validate(uploadedFile); // Create the fine tuning job using var requestContent = new FineTuningOptions() @@ -184,6 +168,7 @@ public async Task CreateAndCancelFineTuning() // Wait for some events to become available ClientResult result; ListResponse events; + TimeSpan pollingInterval = Recording!.Mode == RecordedTestMode.Playback ? TimeSpan.FromMilliseconds(1) : TimeSpan.FromSeconds(2); int maxLoops = 10; do { @@ -201,7 +186,7 @@ public async Task CreateAndCancelFineTuning() break; } - await Task.Delay(TimeSpan.FromSeconds(2)); + await Task.Delay(pollingInterval); } while (maxLoops-- > 0); @@ -221,24 +206,7 @@ public async Task CreateAndDeleteFineTuning() FineTuningClient client = GetTestClient(); OpenAIFileClient fileClient = GetTestClientFrom(client); - OpenAIFile uploadedFile; - try - { - ClientResult fileResult = await fileClient.GetFileAsync("file-db5f5bfe5ea04ffcaeba89947a872828", new RequestOptions() { }); - uploadedFile = ValidateAndParse(fileResult); - } - catch (ClientResultException e) - { - if (e.Message.Contains("ResourceNotFound")) - { - // upload training data - uploadedFile = await UploadAndWaitForCompleteOrFail(fileClient, fineTuningFile.RelativePath); - } - else - { - throw; - } - } + OpenAIFile uploadedFile = await UploadAndWaitForCompleteOrFail(fileClient, fineTuningFile.RelativePath); // Create the fine tuning job using var requestContent = new FineTuningOptions() @@ -402,7 +370,7 @@ private async IAsyncEnumerable EnumerateAsync(Func DeleteJobAndVerifyAsync(AzureFineTuningJobOperation operation, string jobId, TimeSpan? timeBetween = null, TimeSpan? maxWaitTime = null) { var stopTime = DateTimeOffset.Now + (maxWaitTime ?? TimeSpan.FromMinutes(1)); - var sleepTime = timeBetween ?? TimeSpan.FromSeconds(2); + TimeSpan sleepTime = timeBetween ?? (Recording!.Mode == RecordedTestMode.Playback ? TimeSpan.FromMilliseconds(1): TimeSpan.FromSeconds(2)); RequestOptions noThrow = new() { diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ImageTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ImageTests.cs index e97480a2a..9c67c1ca6 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ImageTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ImageTests.cs @@ -68,7 +68,6 @@ public async Task CanGetContentFilterResults() GeneratedImage image = imageResult.Value; Assert.That(image, Is.Not.Null); Assert.That(image.ImageUri, Is.Not.Null); - Console.WriteLine($"RESPONSE--\n{imageResult.GetRawResponse().Content}"); RequestImageContentFilterResult promptResults = image.GetRequestContentFilterResult(); ResponseImageContentFilterResult responseResults = image.GetResponseContentFilterResult(); Assert.That(promptResults?.Sexual?.Severity, Is.EqualTo(ContentFilterSeverity.Safe)); diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Utils/AoaiTestBase.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Utils/AoaiTestBase.cs index 6a3b3118e..674dbfe96 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Utils/AoaiTestBase.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Utils/AoaiTestBase.cs @@ -641,10 +641,18 @@ protected void Cleanup() }); RequestOptions requestOptions = new() { ErrorOptions = ClientErrorBehaviors.NoThrow, }; + void WriteIfNotSuppressed(string message) + { + if (Environment.GetEnvironmentVariable("AOAI_SUPPRESS_TRAFFIC_DUMP") != "true") + { + Console.WriteLine(message); + } + } + OpenAIFileClient fileClient = topLevelCleanupClient.GetOpenAIFileClient(); foreach (string fileId in _fileIdsToDelete) { - Console.WriteLine($"Cleanup: {fileId} -> {fileClient.DeleteFile(fileId, requestOptions)?.GetRawResponse().Status}"); + WriteIfNotSuppressed($"Cleanup: {fileId} -> {fileClient.DeleteFile(fileId, requestOptions)?.GetRawResponse().Status}"); } _fileIdsToDelete.Clear(); @@ -659,23 +667,23 @@ protected void Cleanup() VectorStoreClient vectorStoreClient = topLevelCleanupClient.GetVectorStoreClient(); foreach ((string threadId, string messageId) in _threadIdsWithMessageIdsToDelete) { - Console.WriteLine($"Cleanup: {messageId} -> {client.DeleteMessage(threadId, messageId, requestOptions)?.GetRawResponse().Status}"); + WriteIfNotSuppressed($"Cleanup: {messageId} -> {client.DeleteMessage(threadId, messageId, requestOptions)?.GetRawResponse().Status}"); } foreach (string assistantId in _assistantIdsToDelete) { - Console.WriteLine($"Cleanup: {assistantId} -> {client.DeleteAssistant(assistantId, requestOptions)?.GetRawResponse().Status}"); + WriteIfNotSuppressed($"Cleanup: {assistantId} -> {client.DeleteAssistant(assistantId, requestOptions)?.GetRawResponse().Status}"); } foreach (string threadId in _threadIdsToDelete) { - Console.WriteLine($"Cleanup: {threadId} -> {client.DeleteThread(threadId, requestOptions)?.GetRawResponse().Status}"); + WriteIfNotSuppressed($"Cleanup: {threadId} -> {client.DeleteThread(threadId, requestOptions)?.GetRawResponse().Status}"); } foreach ((string vectorStoreId, string fileId) in _vectorStoreFileAssociationsToRemove) { - Console.WriteLine($"Cleanup: {vectorStoreId}<->{fileId} => {vectorStoreClient.RemoveFileFromStore(vectorStoreId, fileId, requestOptions)?.GetRawResponse().Status}"); + WriteIfNotSuppressed($"Cleanup: {vectorStoreId}<->{fileId} => {vectorStoreClient.RemoveFileFromStore(vectorStoreId, fileId, requestOptions)?.GetRawResponse().Status}"); } foreach (string vectorStoreId in _vectorStoreIdsToDelete) { - Console.WriteLine($"Cleanup: {vectorStoreId} => {vectorStoreClient.DeleteVectorStore(vectorStoreId, requestOptions)?.GetRawResponse().Status}"); + WriteIfNotSuppressed($"Cleanup: {vectorStoreId} => {vectorStoreClient.DeleteVectorStore(vectorStoreId, requestOptions)?.GetRawResponse().Status}"); } _threadIdsWithMessageIdsToDelete.Clear(); _assistantIdsToDelete.Clear(); @@ -756,6 +764,6 @@ public TestClientOptions() : base() public TestClientOptions(ServiceVersion version) : base(version) { } - public bool ShouldOutputRequests { get; set; } = true; - public bool ShouldOutputResponses { get; set; } = true; + public bool ShouldOutputRequests { get; set; } = Environment.GetEnvironmentVariable("AOAI_SUPPRESS_TRAFFIC_DUMP") != "true"; + public bool ShouldOutputResponses { get; set; } = Environment.GetEnvironmentVariable("AOAI_SUPPRESS_TRAFFIC_DUMP") != "true"; } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/VectorStoreTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/VectorStoreTests.cs index 3443a1947..f38a462d5 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/VectorStoreTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/VectorStoreTests.cs @@ -176,7 +176,8 @@ public async Task CanAssociateFiles() Assert.True(removalResult.Removed); // Errata: removals aren't immediately reflected when requesting the list - await Task.Delay(TimeSpan.FromSeconds(5)); + TimeSpan waitTime = Recording!.Mode == RecordedTestMode.Playback ? TimeSpan.FromMilliseconds(1) : TimeSpan.FromSeconds(10); + await Task.Delay(waitTime); int count = 0; AsyncCollectionResult response = client.GetFileAssociationsAsync(vectorStore.Id); diff --git a/.dotnet.azure/sdk/openai/tools/TestFramework/src/RecordedTestAttribute.cs b/.dotnet.azure/sdk/openai/tools/TestFramework/src/RecordedTestAttribute.cs index 5f98e8d75..f52e063e5 100644 --- a/.dotnet.azure/sdk/openai/tools/TestFramework/src/RecordedTestAttribute.cs +++ b/.dotnet.azure/sdk/openai/tools/TestFramework/src/RecordedTestAttribute.cs @@ -121,7 +121,8 @@ private static bool IsRecordingPlaybackFailure(TestResult result) // 2. Check if the failure message indicates a recording playback exception. This sadly requires us to check test failure // messages which can be a little fragile but there does not seem to be a way to get the exception directly - if (result.Message?.Contains(exceptionName) == true) + if (result.Message?.Contains(exceptionName) == true + || result.Message?.Contains("ClientResultException : NotFound: Recording file path") == true) { return true; } diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f19a24acc..d330bdf99 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -112,11 +112,11 @@ jobs: --no-build --filter "(TestCategory!=Live)" --logger "trx;LogFileName=Azure.AI.OpenAI.Tests.trx" - --logger:"console;verbosity=quiet" --blame-crash-dump-type full --blame-hang-dump-type full --blame-hang-timeout 15minutes --results-directory "${{github.workspace}}/TestResults" + -e AOAI_SUPPRESS_TRAFFIC_DUMP="true" Azure.AI.OpenAI/tests/Azure.AI.OpenAI.Tests.csproj working-directory: .dotnet.azure/sdk/openai diff --git a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml index 0ea9c6b83..d6983afce 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml @@ -1055,6 +1055,7 @@ components: - 2024-09-01-preview - 2024-10-01-preview - 2024-10-21 + - 2024-12-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml index 2066a2ca9..95f71ab9c 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml @@ -993,6 +993,7 @@ components: - 2024-09-01-preview - 2024-10-01-preview - 2024-10-21 + - 2024-12-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml index 335eec92a..9a0325be9 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml @@ -993,6 +993,7 @@ components: - 2024-09-01-preview - 2024-10-01-preview - 2024-10-21 + - 2024-12-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml index 08194da76..e99981b86 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml @@ -1028,6 +1028,7 @@ components: - 2024-09-01-preview - 2024-10-01-preview - 2024-10-21 + - 2024-12-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml index 3ba630394..55f5b98bf 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml @@ -1064,6 +1064,7 @@ components: - 2024-09-01-preview - 2024-10-01-preview - 2024-10-21 + - 2024-12-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-11-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-11-01-preview-generated.yaml new file mode 100644 index 000000000..325032619 --- /dev/null +++ b/.openapi3.azure/openapi3-azure-openai-2024-11-01-preview-generated.yaml @@ -0,0 +1,3197 @@ +openapi: 3.0.0 +info: + title: Azure OpenAI Service + version: 2024-12-01-preview +tags: + - name: Chat + - name: Images + - name: Assistants +paths: + /chat/completions: + post: + operationId: createChatCompletion + parameters: [] + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' + tags: + - Chat + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AzureCreateChatCompletionRequest' + /deployments/{deploymentId}/images/generations: + post: + operationId: ImageGenerations_Create + parameters: + - name: deploymentId + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/OpenAI.ImagesResponse' + - $ref: '#/components/schemas/AzureOpenAIDalleErrorResponse' + tags: + - Images + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.CreateImageRequest' + /threads/{thread_id}/messages: + post: + operationId: createMessage + summary: Create a message. + parameters: + - name: thread_id + in: path + required: true + description: The ID of the [thread](/docs/api-reference/threads) to create a message for. + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.MessageObject' + default: + description: An unexpected error response. + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.ErrorResponse' + tags: + - Assistants + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.CreateMessageRequest' +security: + - ApiKeyAuth: [] + - OAuth2Auth: + - https://cognitiveservices.azure.com/.default +components: + schemas: + AzureChatCompletionResponseMessage: + type: object + properties: + context: + allOf: + - $ref: '#/components/schemas/AzureChatMessageContext' + description: The Azure-specific context information associated with the chat completion response message. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + description: |- + The extended response model component for chat completion response messages on the Azure OpenAI service. + This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other + information related to retrieval-augmented generation performed. + AzureChatCompletionStreamResponseDelta: + type: object + properties: + context: + allOf: + - $ref: '#/components/schemas/AzureChatMessageContext' + description: The Azure-specific context information associated with the chat completion response message. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' + description: |- + The extended response model for a streaming chat response message on the Azure OpenAI service. + This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other + information related to retrieval-augmented generation performed. + AzureChatDataSource: + type: object + required: + - type + properties: + type: + type: string + description: The differentiating type identifier for the data source. + discriminator: + propertyName: type + mapping: + azure_search: '#/components/schemas/AzureSearchChatDataSource' + azure_cosmos_db: '#/components/schemas/AzureCosmosDBChatDataSource' + elasticsearch: '#/components/schemas/ElasticsearchChatDataSource' + pinecone: '#/components/schemas/PineconeChatDataSource' + mongo_db: '#/components/schemas/MongoDBChatDataSource' + description: |- + A representation of configuration data for a single Azure OpenAI chat data source. + This will be used by a chat completions request that should use Azure OpenAI chat extensions to augment the + response behavior. + The use of this configuration is compatible only with Azure OpenAI. + AzureChatDataSourceAccessTokenAuthenticationOptions: + type: object + required: + - type + - access_token + properties: + type: + type: string + enum: + - access_token + access_token: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceApiKeyAuthenticationOptions: + type: object + required: + - type + - key + properties: + type: + type: string + enum: + - api_key + key: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceAuthenticationOptions: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' + connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' + encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' + access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + AzureChatDataSourceConnectionStringAuthenticationOptions: + type: object + required: + - type + - connection_string + properties: + type: + type: string + enum: + - connection_string + connection_string: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceDeploymentNameVectorizationSource: + type: object + required: + - type + - deployment_name + properties: + type: + type: string + enum: + - deployment_name + description: The type identifier, always 'deployment_name' for this vectorization source type. + deployment_name: + type: string + description: |- + The embedding model deployment to use for vectorization. This deployment must exist within the same Azure OpenAI + resource as the model deployment being used for chat completions. + dimensions: + type: integer + format: int32 + description: |- + The number of dimensions to request on embeddings. + Only supported in 'text-embedding-3' and later models. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: |- + Represents a vectorization source that makes internal service calls against an Azure OpenAI embedding model + deployment. In contrast with the endpoint-based vectorization source, a deployment-name-based vectorization source + must be part of the same Azure OpenAI resource but can be used even in private networks. + AzureChatDataSourceEncodedApiKeyAuthenticationOptions: + type: object + required: + - type + - encoded_api_key + properties: + type: + type: string + enum: + - encoded_api_key + encoded_api_key: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceEndpointVectorizationSource: + type: object + required: + - type + - endpoint + - authentication + properties: + type: + type: string + enum: + - endpoint + description: The type identifier, always 'endpoint' for this vectorization source type. + endpoint: + type: string + format: uri + description: |- + Specifies the resource endpoint URL from which embeddings should be retrieved. + It should be in the format of: + https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. + The api-version query parameter is not allowed. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: |- + The authentication mechanism to use with the endpoint-based vectorization source. + Endpoint authentication supports API key and access token mechanisms. + dimensions: + type: integer + format: int32 + description: |- + The number of dimensions to request on embeddings. + Only supported in 'text-embedding-3' and later models. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: Represents a vectorization source that makes public service calls against an Azure OpenAI embedding model deployment. + AzureChatDataSourceIntegratedVectorizationSource: + type: object + required: + - type + properties: + type: + type: string + enum: + - integrated + description: The type identifier, always 'integrated' for this vectorization source type. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: Represents an integrated vectorization source as defined within the supporting search resource. + AzureChatDataSourceKeyAndKeyIdAuthenticationOptions: + type: object + required: + - type + - key + - key_id + properties: + type: + type: string + enum: + - key_and_key_id + key: + type: string + key_id: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceModelIdVectorizationSource: + type: object + required: + - type + - model_id + properties: + type: + type: string + enum: + - model_id + description: The type identifier, always 'model_id' for this vectorization source type. + model_id: + type: string + description: The embedding model build ID to use for vectorization. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: |- + Represents a vectorization source that makes service calls based on a search service model ID. + This source type is currently only supported by Elasticsearch. + AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions: + type: object + required: + - type + properties: + type: + type: string + enum: + - system_assigned_managed_identity + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions: + type: object + required: + - type + - managed_identity_resource_id + properties: + type: + type: string + enum: + - user_assigned_managed_identity + managed_identity_resource_id: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceUsernameAndPasswordAuthenticationOptions: + type: object + required: + - type + - username + - password + properties: + type: + type: string + enum: + - username_and_password + username: + type: string + password: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceVectorizationSource: + type: object + required: + - type + properties: + type: + type: string + description: The differentiating identifier for the concrete vectorization source. + discriminator: + propertyName: type + mapping: + deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' + integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: A representation of a data vectorization source usable as an embedding resource with a data source. + AzureChatMessageContext: + type: object + properties: + intent: + type: string + description: The detected intent from the chat history, which is used to carry conversation context between interactions + citations: + type: array + items: + type: object + properties: + content: + type: string + description: The content of the citation. + title: + type: string + description: The title for the citation. + url: + type: string + description: The URL of the citation. + filepath: + type: string + description: The file path for the citation. + chunk_id: + type: string + description: The chunk ID for the citation. + rerank_score: + type: number + format: double + description: The rerank score for the retrieval. + required: + - content + description: The citations produced by the data retrieval. + all_retrieved_documents: + type: object + properties: + content: + type: string + description: The content of the citation. + title: + type: string + description: The title for the citation. + url: + type: string + description: The URL of the citation. + filepath: + type: string + description: The file path for the citation. + chunk_id: + type: string + description: The chunk ID for the citation. + rerank_score: + type: number + format: double + description: The rerank score for the retrieval. + search_queries: + type: array + items: + type: string + description: The search queries executed to retrieve documents. + data_source_index: + type: integer + format: int32 + description: The index of the data source used for retrieval. + original_search_score: + type: number + format: double + description: The original search score for the retrieval. + filter_reason: + type: string + enum: + - score + - rerank + description: If applicable, an indication of why the document was filtered. + required: + - content + - search_queries + - data_source_index + description: Summary information about documents retrieved by the data retrieval operation. + description: |- + An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using + extension behavior. This includes intent and citation information from the On Your Data feature. + AzureContentFilterBlocklistIdResult: + type: object + required: + - id + - filtered + properties: + id: + type: string + description: The ID of the custom blocklist associated with the filtered status. + filtered: + type: boolean + description: Whether the associated blocklist resulted in the content being filtered. + description: |- + A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not + the corresponding blocklist resulted in content being filtered. + AzureContentFilterBlocklistResult: + type: object + required: + - filtered + properties: + filtered: + type: boolean + description: A value indicating whether any of the detailed blocklists resulted in a filtering action. + details: + type: array + items: + type: object + properties: + filtered: + type: boolean + description: A value indicating whether the blocklist produced a filtering action. + id: + type: string + description: The ID of the custom blocklist evaluated. + required: + - filtered + - id + description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. + description: A collection of true/false filtering results for configured custom blocklists. + AzureContentFilterCompletionTextSpan: + type: object + required: + - completion_start_offset + - completion_end_offset + properties: + completion_start_offset: + type: integer + format: int32 + description: Offset of the UTF32 code point which begins the span. + completion_end_offset: + type: integer + format: int32 + description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. + description: A representation of a span of completion text as used by Azure OpenAI content filter results. + AzureContentFilterCompletionTextSpanDetectionResult: + type: object + required: + - filtered + - detected + - details + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + details: + type: array + items: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' + description: Detailed information about the detected completion text spans. + AzureContentFilterDetectionResult: + type: object + required: + - filtered + - detected + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + description: |- + A labeled content filter result item that indicates whether the content was detected and whether the content was + filtered. + AzureContentFilterImagePromptResults: + type: object + required: + - jailbreak + properties: + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + jailbreak: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that describes user prompt injection attacks, where malicious users deliberately exploit + system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content + generation or violations of system-imposed restrictions. + allOf: + - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + description: A content filter result for an image generation operation's input request content. + AzureContentFilterImageResponseResults: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + ungrounded_material: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' + description: A content filter result for a single response item produced by a generative AI system. + AzureContentFilterResultForPrompt: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt associated with the accompanying content filter result categories. + content_filter_results: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + jailbreak: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that describes user prompt injection attacks, where malicious users deliberately exploit + system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content + generation or violations of system-imposed restrictions. + indirect_attack: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that describes attacks on systems powered by Generative AI models that can happen every time + an application processes information that wasn’t directly authored by either the developer of the application or + the user. + required: + - jailbreak + - indirect_attack + description: The content filter category details for the result. + description: A content filter result associated with a single input prompt item into a generative AI system. + AzureContentFilterSeverityResult: + type: object + required: + - filtered + - severity + properties: + filtered: + type: boolean + description: Whether the content severity resulted in a content filtering action. + severity: + type: string + enum: + - safe + - low + - medium + - high + description: The labeled severity of the content. + description: |- + A labeled content filter result item that indicates whether the content was filtered and what the qualitative + severity level of the content was, as evaluated against content filter configuration for the category. + AzureCosmosDBChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_cosmos_db + description: The discriminated type identifier, which is always 'azure_cosmos_db'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + container_name: + type: string + database_name: + type: string + embedding_dependency: + $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + index_name: + type: string + authentication: + $ref: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + fields_mapping: + type: object + properties: + content_fields: + type: array + items: + type: string + vector_fields: + type: array + items: + type: string + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields_separator: + type: string + required: + - content_fields + - vector_fields + required: + - container_name + - database_name + - embedding_dependency + - index_name + - authentication + - fields_mapping + description: The parameter information to control the use of the Azure CosmosDB data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure CosmosDB resource. + AzureCreateChatCompletionRequest: + type: object + properties: + data_sources: + type: array + items: + $ref: '#/components/schemas/AzureChatDataSource' + description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. + user_security_context: + $ref: '#/components/schemas/AzureUserSecurityContext' + allOf: + - $ref: '#/components/schemas/OpenAI.CreateChatCompletionRequest' + description: |- + The extended request model for chat completions against the Azure OpenAI service. + This adds the ability to provide data sources for the On Your Data feature. + AzureCreateChatCompletionResponse: + type: object + properties: + prompt_filter_results: + type: array + items: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt that this content filter result corresponds to. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter results associated with the indexed input prompt. + required: + - prompt_index + - content_filter_results + description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. + allOf: + - $ref: '#/components/schemas/OpenAI.CreateChatCompletionResponse' + description: |- + The extended top-level chat completion response model for the Azure OpenAI service. + This model adds Responsible AI content filter annotations for prompt input. + AzureImage: + type: object + required: + - prompt_filter_results + - content_filter_results + properties: + prompt_filter_results: + $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + content_filter_results: + $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + allOf: + - $ref: '#/components/schemas/OpenAI.Image' + AzureOpenAIChatError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI chat completion request. + AzureOpenAIChatErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIChatError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIDalleError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI image generation request. + AzureOpenAIDalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIDalleError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIFile: + type: object + required: + - id + - bytes + - created_at + - filename + - object + - purpose + - status + properties: + id: + type: string + description: The file identifier, which can be referenced in the API endpoints. + bytes: + type: integer + format: int32 + nullable: true + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + filename: + type: string + description: The name of the file. + object: + type: string + enum: + - file + description: The object type, which is always `file`. + purpose: + type: string + enum: + - assistants + - assistants_output + - batch + - batch_output + - fine-tune + - fine-tune-results + - vision + description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. + status_details: + type: string + description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + deprecated: true + status: + type: string + enum: + - uploaded + - pending + - running + - processed + - error + - deleting + - deleted + AzureOpenAIServiceApiVersion: + type: string + enum: + - 2024-06-01 + - 2024-08-01-preview + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 + - 2024-12-01-preview + description: Known service API versions for Azure OpenAI. + AzureSearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_search + description: The discriminated type identifier, which is always 'azure_search'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + description: The absolute endpoint path for the Azure Search resource to use. + index_name: + type: string + description: The name of the index to use, as specified in the Azure Search resource. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: The authentication mechanism to use with Azure Search. + fields_mapping: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + items: + type: string + description: The names of index fields that should be treated as content. + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + items: + type: string + description: The names of fields that represent vector data. + image_vector_fields: + type: array + items: + type: string + description: The names of fields that represent image vector data. + description: The field mappings to use with the Azure Search resource. + query_type: + type: string + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: + type: string + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + AzureUserSecurityContext: + type: object + properties: + application_name: + type: string + description: The name of the application. Sensitive personal information should not be included in this field. + end_user_id: + type: string + description: This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. + end_user_tenant_id: + type: string + description: The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. + source_ip: + type: string + description: Captures the original client's IP address. + description: User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionTokenLogprobBytes: + type: array + items: + type: integer + format: int32 + CreateMessageRequestAttachments: + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools + ElasticsearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - elasticsearch + description: The discriminated type identifier, which is always 'elasticsearch'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + index_name: + type: string + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' + fields_mapping: + type: object + properties: + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields: + type: array + items: + type: string + content_fields_separator: + type: string + vector_fields: + type: array + items: + type: string + query_type: + type: string + enum: + - simple + - vector + embedding_dependency: + $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Elasticsearch data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + MessageObjectAttachments: + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + MongoDBChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - mongo_db + description: The discriminated type identifier, which is always 'mongo_db'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + description: The name of the MongoDB cluster endpoint. + database_name: + type: string + description: The name of the MongoDB database. + collection_name: + type: string + description: The name of the MongoDB collection. + app_name: + type: string + description: The name of the MongoDB application. + index_name: + type: string + description: The name of the MongoDB index. + authentication: + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' + description: |- + The authentication mechanism to use with Pinecone. + Supported authentication mechanisms for Pinecone include: username and password. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + description: |- + The vectorization source to use as an embedding dependency for the MongoDB data source. + Supported vectorization sources for MongoDB include: endpoint, deployment name. + fields_mapping: + type: object + properties: + content_fields: + type: array + items: + type: string + vector_fields: + type: array + items: + type: string + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields_separator: + type: string + required: + - content_fields + - vector_fields + description: |- + Field mappings to apply to data used by the MongoDB data source. + Note that content and vector field mappings are required for MongoDB. + required: + - endpoint + - database_name + - collection_name + - app_name + - index_name + - authentication + - embedding_dependency + - fields_mapping + description: The parameter information to control the use of the MongoDB data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + OpenAI.AssistantToolDefinition: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + file_search: '#/components/schemas/OpenAI.AssistantToolsFileSearch' + function: '#/components/schemas/OpenAI.AssistantToolsFunction' + OpenAI.AssistantToolsCode: + type: object + required: + - type + properties: + type: + type: string + enum: + - code_interpreter + description: 'The type of tool being defined: `code_interpreter`' + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.AssistantToolsFileSearch: + type: object + required: + - type + properties: + type: + type: string + enum: + - file_search + description: 'The type of tool being defined: `file_search`' + file_search: + type: object + properties: + max_num_results: + type: integer + format: int32 + minimum: 1 + maximum: 50 + description: |- + The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + ranking_options: + $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' + description: Overrides for the file search tool. + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.AssistantToolsFileSearchTypeOnly: + type: object + required: + - type + properties: + type: + type: string + enum: + - file_search + description: 'The type of tool being defined: `file_search`' + OpenAI.AssistantToolsFunction: + type: object + required: + - type + - function + properties: + type: + type: string + enum: + - function + description: 'The type of tool being defined: `function`' + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.ChatCompletionFunctionCallOption: + type: object + required: + - name + properties: + name: + type: string + description: The name of the function to call. + description: 'Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.' + OpenAI.ChatCompletionFunctions: + type: object + required: + - name + properties: + description: + type: string + description: A description of what the function does, used by the model to choose when and how to call the function. + name: + type: string + description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/OpenAI.FunctionParameters' + deprecated: true + OpenAI.ChatCompletionMessageToolCall: + type: object + required: + - id + - type + - function + properties: + id: + type: string + description: The ID of the tool call. + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + arguments: + type: string + description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. + required: + - name + - arguments + description: The function that the model called. + OpenAI.ChatCompletionMessageToolCallChunk: + type: object + required: + - index + properties: + index: + type: integer + format: int32 + id: + type: string + description: The ID of the tool call. + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + arguments: + type: string + description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. + OpenAI.ChatCompletionNamedToolChoice: + type: object + required: + - type + - function + properties: + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + required: + - name + description: Specifies a tool the model should use. Use to force the model to call a specific function. + OpenAI.ChatCompletionRequestAssistantMessage: + type: object + required: + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessageContentPart' + nullable: true + description: The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. + x-oaiExpandable: true + refusal: + type: string + nullable: true + description: The refusal message by the assistant. + role: + type: string + enum: + - assistant + description: The role of the messages author, in this case `assistant`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + nullable: true + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestAssistantMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestFunctionMessage: + type: object + required: + - role + - content + - name + properties: + role: + type: string + enum: + - function + description: The role of the messages author, in this case `function`. + content: + type: string + nullable: true + description: The contents of the function message. + name: + type: string + description: The name of the function to call. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + deprecated: true + OpenAI.ChatCompletionRequestMessage: + type: object + required: + - role + properties: + role: + type: string + description: The role of the author of this message. + discriminator: + propertyName: role + mapping: + system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' + assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' + tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' + function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartImage: + type: object + required: + - type + - image_url + properties: + type: + type: string + enum: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: Either a URL of the image or the base64 encoded image data. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + default: auto + required: + - url + OpenAI.ChatCompletionRequestMessageContentPartRefusal: + type: object + required: + - type + - refusal + properties: + type: + type: string + enum: + - refusal + description: The type of the content part. + refusal: + type: string + description: The refusal message generated by the model. + OpenAI.ChatCompletionRequestMessageContentPartText: + type: object + required: + - type + - text + properties: + type: + type: string + enum: + - text + description: The type of the content part. + text: + type: string + description: The text content. + OpenAI.ChatCompletionRequestSystemMessage: + type: object + required: + - content + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + description: The contents of the system message. + role: + type: string + enum: + - system + description: The role of the messages author, in this case `system`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestSystemMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestToolMessage: + type: object + required: + - role + - content + - tool_call_id + properties: + role: + type: string + enum: + - tool + description: The role of the messages author, in this case `tool`. + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' + description: The contents of the tool message. + tool_call_id: + type: string + description: Tool call that this message is responding to. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestToolMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestUserMessage: + type: object + required: + - content + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' + description: The contents of the user message. + x-oaiExpandable: true + role: + type: string + enum: + - user + description: The role of the messages author, in this case `user`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestUserMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + x-oaiExpandable: true + OpenAI.ChatCompletionResponseMessage: + type: object + required: + - content + - refusal + - role + properties: + content: + type: string + nullable: true + description: The contents of the message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + role: + type: string + enum: + - assistant + description: The role of the author of this message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + description: A chat completion message generated by the model. + OpenAI.ChatCompletionStreamOptions: + type: object + properties: + include_usage: + type: boolean + description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' + description: 'Options for streaming response. Only set this when you set `stream: true`.' + OpenAI.ChatCompletionStreamResponseDelta: + type: object + properties: + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + description: A chat completion delta generated by streamed model responses. + OpenAI.ChatCompletionTokenLogprob: + type: object + required: + - token + - logprob + - bytes + - top_logprobs + properties: + token: + type: string + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + top_logprobs: + type: array + items: + type: object + properties: + token: + type: string + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: array + items: + type: integer + format: int32 + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + required: + - token + - logprob + - bytes + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + OpenAI.ChatCompletionTool: + type: object + required: + - type + - function + properties: + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + OpenAI.ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - auto + - required + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' + description: |- + Controls which (if any) tool is called by the model. + `none` means the model will not call any tool and instead generates a message. + `auto` means the model can pick between generating a message or calling one or more tools. + `required` means the model must call one or more tools. + Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + + `none` is the default when no tools are present. `auto` is the default if tools are present. + x-oaiExpandable: true + OpenAI.ChatResponseFormat: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/OpenAI.ChatResponseFormatText' + json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' + json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' + OpenAI.ChatResponseFormatJsonObject: + type: object + required: + - type + properties: + type: + type: string + enum: + - json_object + description: 'The type of response format being defined: `json_object`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatJsonSchema: + type: object + required: + - type + - json_schema + properties: + type: + type: string + enum: + - json_schema + description: 'The type of response format being defined: `json_schema`' + json_schema: + type: object + properties: + description: + type: string + description: A description of what the response format is for, used by the model to determine how to respond in the format. + name: + type: string + description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + default: false + required: + - name + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatText: + type: object + required: + - type + properties: + type: + type: string + enum: + - text + description: 'The type of response format being defined: `text`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + audio_tokens: + type: integer + format: int32 + description: Audio input tokens generated by the model. + reasoning_tokens: + type: integer + format: int32 + description: Tokens generated by the model for reasoning. + required: + - audio_tokens + - reasoning_tokens + description: Breakdown of tokens used in a completion. + prompt_tokens_details: + type: object + properties: + audio_tokens: + type: integer + format: int32 + description: Audio input tokens present in the prompt. + cached_tokens: + type: integer + format: int32 + description: Cached tokens present in the prompt. + required: + - audio_tokens + - cached_tokens + description: Breakdown of tokens used in the prompt. + description: Usage statistics for the completion request. + OpenAI.CreateChatCompletionRequest: + type: object + required: + - messages + - model + properties: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + model: + anyOf: + - type: string + - type: string + enum: + - o1-preview + - o1-preview-2024-09-12 + - o1-mini + - o1-mini-2024-09-12 + - gpt-4o + - gpt-4o-2024-08-06 + - gpt-4o-2024-05-13 + - gpt-4o-realtime-preview + - gpt-4o-realtime-preview-2024-10-01 + - chatgpt-4o-latest + - gpt-4o-mini + - gpt-4o-mini-2024-07-18 + - gpt-4-turbo + - gpt-4-turbo-2024-04-09 + - gpt-4-0125-preview + - gpt-4-turbo-preview + - gpt-4-1106-preview + - gpt-4-vision-preview + - gpt-4 + - gpt-4-0314 + - gpt-4-0613 + - gpt-4-32k + - gpt-4-32k-0314 + - gpt-4-32k-0613 + - gpt-3.5-turbo + - gpt-3.5-turbo-16k + - gpt-3.5-turbo-0301 + - gpt-3.5-turbo-0613 + - gpt-3.5-turbo-1106 + - gpt-3.5-turbo-0125 + - gpt-3.5-turbo-16k-0613 + description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. + x-oaiTypeLabel: string + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + service_tier: + type: string + enum: + - auto + - default + nullable: true + description: |- + Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: + - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. + - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + - When not set, the default behavior is 'auto'. + + When this parameter is set, the response body will include the `service_tier` utilized. + default: auto + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + OpenAI.CreateChatCompletionResponse: + type: object + required: + - id + - choices + - created + - model + - object + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + usage: + $ref: '#/components/schemas/OpenAI.CompletionUsage' + description: Represents a chat completion response returned by model, based on the provided input. + OpenAI.CreateImageRequest: + type: object + required: + - prompt + properties: + prompt: + type: string + description: A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`. + model: + anyOf: + - type: string + - type: string + enum: + - dall-e-2 + - dall-e-3 + nullable: true + description: The model to use for image generation. + x-oaiTypeLabel: string + default: dall-e-2 + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 10 + description: The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported. + default: 1 + quality: + type: string + enum: + - standard + - hd + description: The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`. + default: standard + response_format: + type: string + enum: + - url + - b64_json + nullable: true + description: The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. + default: url + size: + type: string + enum: + - 256x256 + - 512x512 + - 1024x1024 + - 1792x1024 + - 1024x1792 + nullable: true + description: The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3` models. + default: 1024x1024 + style: + type: string + enum: + - vivid + - natural + nullable: true + description: The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`. + default: vivid + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + OpenAI.CreateMessageRequest: + type: object + required: + - role + - content + properties: + role: + type: string + enum: + - user + - assistant + description: |- + The role of the entity that is creating the message. Allowed values include: + - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. + - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContent' + x-oaiExpandable: true + attachments: + type: object + allOf: + - $ref: '#/components/schemas/CreateMessageRequestAttachments' + nullable: true + description: A list of files attached to the message, and the tools they should be added to. + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + x-oaiTypeLabel: map + OpenAI.Error: + type: object + required: + - code + - message + - param + - type + properties: + code: + type: string + nullable: true + message: + type: string + param: + type: string + nullable: true + type: + type: string + OpenAI.ErrorResponse: + type: object + required: + - error + properties: + error: + $ref: '#/components/schemas/OpenAI.Error' + OpenAI.FileSearchRankingOptions: + type: object + required: + - score_threshold + properties: + ranker: + type: string + enum: + - auto + - default_2024_08_21 + description: The ranker to use for the file search. If not specified will use the `auto` ranker. + score_threshold: + type: number + format: float + minimum: 0 + maximum: 1 + description: The score threshold for the file search. All values must be a floating point number between 0 and 1. + description: |- + The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + + See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + OpenAI.FunctionObject: + type: object + required: + - name + properties: + description: + type: string + description: A description of what the function does, used by the model to choose when and how to call the function. + name: + type: string + description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/OpenAI.FunctionParameters' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling). + default: false + OpenAI.FunctionParameters: + type: object + additionalProperties: {} + description: |- + The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + + Omitting `parameters` defines a function with an empty parameter list. + OpenAI.Image: + type: object + properties: + b64_json: + type: string + format: base64 + description: The base64-encoded JSON of the generated image, if `response_format` is `b64_json`. + url: + type: string + format: uri + description: The URL of the generated image, if `response_format` is `url` (default). + revised_prompt: + type: string + description: The prompt that was used to generate the image, if there was any revision to the prompt. + description: Represents the url or the content of an image generated by the OpenAI API. + OpenAI.ImagesResponse: + type: object + required: + - created + - data + properties: + created: + type: integer + format: unixtime + data: + type: array + items: + $ref: '#/components/schemas/OpenAI.Image' + OpenAI.MessageContent: + type: object + description: Represents a single piece of content in an Assistants API message. + OpenAI.MessageContentImageFileObject: + type: object + required: + - type + - image_file + properties: + type: + type: string + enum: + - image_file + description: Always `image_file`. + image_file: + type: object + properties: + file_id: + type: string + description: The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. + default: auto + required: + - file_id + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: References an image [File](/docs/api-reference/files) in the content of a message. + OpenAI.MessageContentImageUrlObject: + type: object + required: + - type + - image_url + properties: + type: + type: string + enum: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: 'The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.' + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + default: auto + required: + - url + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: References an image URL in the content of a message. + OpenAI.MessageContentRefusalObject: + type: object + required: + - type + - refusal + properties: + type: + type: string + enum: + - refusal + description: Always `refusal`. + refusal: + type: string + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The refusal content generated by the assistant. + OpenAI.MessageContentTextAnnotationsFileCitationObject: + type: object + required: + - type + - text + - file_citation + - start_index + - end_index + properties: + type: + type: string + enum: + - file_citation + description: Always `file_citation`. + text: + type: string + description: The text in the message content that needs to be replaced. + file_citation: + type: object + properties: + file_id: + type: string + description: The ID of the specific File the citation is from. + required: + - file_id + start_index: + type: integer + format: int32 + minimum: 0 + end_index: + type: integer + format: int32 + minimum: 0 + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + description: A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + OpenAI.MessageContentTextAnnotationsFilePathObject: + type: object + required: + - type + - text + - file_path + - start_index + - end_index + properties: + type: + type: string + enum: + - file_path + description: Always `file_path`. + text: + type: string + description: The text in the message content that needs to be replaced. + file_path: + type: object + properties: + file_id: + type: string + description: The ID of the file that was generated. + required: + - file_id + start_index: + type: integer + format: int32 + minimum: 0 + end_index: + type: integer + format: int32 + minimum: 0 + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + description: A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + OpenAI.MessageContentTextObject: + type: object + required: + - type + - text + properties: + type: + type: string + enum: + - text + description: Always `text`. + text: + type: object + properties: + value: + type: string + description: The data that makes up the text. + annotations: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + x-oaiExpandable: true + required: + - value + - annotations + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The text content that is part of a message. + OpenAI.MessageContentTextObjectAnnotation: + type: object + required: + - type + properties: + type: + type: string + description: The discriminated type identifier for the content item. + discriminator: + propertyName: type + mapping: + file_citation: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFileCitationObject' + file_path: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFilePathObject' + OpenAI.MessageObject: + type: object + required: + - id + - object + - created_at + - thread_id + - status + - incomplete_details + - completed_at + - incomplete_at + - role + - content + - assistant_id + - run_id + - attachments + - metadata + properties: + id: + type: string + description: The identifier, which can be referenced in API endpoints. + object: + type: string + enum: + - thread.message + description: The object type, which is always `thread.message`. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the message was created. + thread_id: + type: string + description: The [thread](/docs/api-reference/threads) ID that this message belongs to. + status: + type: string + enum: + - in_progress + - incomplete + - completed + description: The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + incomplete_details: + type: object + properties: + reason: + type: string + enum: + - content_filter + - max_tokens + - run_cancelled + - run_expired + - run_failed + description: The reason the message is incomplete. + required: + - reason + nullable: true + description: On an incomplete message, details about why the message is incomplete. + completed_at: + type: integer + format: unixtime + nullable: true + description: The Unix timestamp (in seconds) for when the message was completed. + incomplete_at: + type: integer + format: unixtime + nullable: true + description: The Unix timestamp (in seconds) for when the message was marked as incomplete. + role: + type: string + enum: + - user + - assistant + description: The entity that produced the message. One of `user` or `assistant`. + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContent' + description: The content of the message in array of text and/or images. + x-oaiExpandable: true + assistant_id: + type: string + nullable: true + description: If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. + run_id: + type: string + nullable: true + description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. + attachments: + type: object + allOf: + - $ref: '#/components/schemas/MessageObjectAttachments' + nullable: true + description: A list of files attached to the message, and the tools they were added to. + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + x-oaiTypeLabel: map + description: Represents a message within a [thread](/docs/api-reference/threads). + OpenAI.MessageRequestContentTextObject: + type: object + required: + - type + - text + properties: + type: + type: string + enum: + - text + description: Always `text`. + text: + type: string + description: Text content to be sent to the model + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The text content that is part of a message. + OpenAI.ResponseFormatJsonSchemaSchema: + type: object + additionalProperties: {} + description: The schema for the response format, described as a JSON Schema object. + OpenAIFileWithOmittedProperties: + type: object + required: + - id + - bytes + - created_at + - filename + - object + - purpose + properties: + id: + type: string + description: The file identifier, which can be referenced in the API endpoints. + bytes: + type: integer + format: int32 + nullable: true + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + filename: + type: string + description: The name of the file. + object: + type: string + enum: + - file + description: The object type, which is always `file`. + purpose: + type: string + enum: + - assistants + - assistants_output + - batch + - batch_output + - fine-tune + - fine-tune-results + - vision + description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. + status_details: + type: string + description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + deprecated: true + description: The `File` object represents a document that has been uploaded to OpenAI. + PineconeChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - pinecone + description: The discriminated type identifier, which is always 'pinecone'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + environment: + type: string + description: The environment name to use with Pinecone. + index_name: + type: string + description: The name of the Pinecone database index to use. + authentication: + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + description: |- + The authentication mechanism to use with Pinecone. + Supported authentication mechanisms for Pinecone include: API key. + embedding_dependency: + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: |- + The vectorization source to use as an embedding dependency for the Pinecone data source. + Supported vectorization sources for Pinecone include: deployment name. + fields_mapping: + type: object + properties: + content_fields: + type: array + items: + type: string + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields_separator: + type: string + required: + - content_fields + description: |- + Field mappings to apply to data used by the Pinecone data source. + Note that content field mappings are required for Pinecone. + required: + - environment + - index_name + - authentication + - embedding_dependency + - fields_mapping + description: The parameter information to control the use of the Pinecone data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + securitySchemes: + ApiKeyAuth: + type: apiKey + in: header + name: api-key + OAuth2Auth: + type: oauth2 + flows: + implicit: + authorizationUrl: https://login.microsoftonline.com/common/oauth2/v2.0/authorize + scopes: + https://cognitiveservices.azure.com/.default: '' +servers: + - url: '{endpoint}/openai' + description: Azure OpenAI APIs for completions and search + variables: + endpoint: + default: '' + description: |- + Supported Cognitive Services endpoints (protocol and hostname, for example: + https://westus.api.cognitive.microsoft.com). diff --git a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml new file mode 100644 index 000000000..09be53cee --- /dev/null +++ b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml @@ -0,0 +1,3199 @@ +openapi: 3.0.0 +info: + title: Azure OpenAI Service + version: 2024-12-01-preview +tags: + - name: Chat + - name: Images + - name: Assistants +paths: + /chat/completions: + post: + operationId: createChatCompletion + parameters: [] + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' + tags: + - Chat + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AzureCreateChatCompletionRequest' + /deployments/{deploymentId}/images/generations: + post: + operationId: ImageGenerations_Create + parameters: + - name: deploymentId + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/OpenAI.ImagesResponse' + - $ref: '#/components/schemas/AzureOpenAIDalleErrorResponse' + tags: + - Images + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.CreateImageRequest' + /threads/{thread_id}/messages: + post: + operationId: createMessage + summary: Create a message. + parameters: + - name: thread_id + in: path + required: true + description: The ID of the [thread](/docs/api-reference/threads) to create a message for. + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.MessageObject' + default: + description: An unexpected error response. + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.ErrorResponse' + tags: + - Assistants + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.CreateMessageRequest' +security: + - ApiKeyAuth: [] + - OAuth2Auth: + - https://cognitiveservices.azure.com/.default +components: + schemas: + AzureChatCompletionResponseMessage: + type: object + properties: + context: + allOf: + - $ref: '#/components/schemas/AzureChatMessageContext' + description: The Azure-specific context information associated with the chat completion response message. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + description: |- + The extended response model component for chat completion response messages on the Azure OpenAI service. + This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other + information related to retrieval-augmented generation performed. + AzureChatCompletionStreamResponseDelta: + type: object + properties: + context: + allOf: + - $ref: '#/components/schemas/AzureChatMessageContext' + description: The Azure-specific context information associated with the chat completion response message. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' + description: |- + The extended response model for a streaming chat response message on the Azure OpenAI service. + This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other + information related to retrieval-augmented generation performed. + AzureChatDataSource: + type: object + required: + - type + properties: + type: + type: string + description: The differentiating type identifier for the data source. + discriminator: + propertyName: type + mapping: + azure_search: '#/components/schemas/AzureSearchChatDataSource' + azure_cosmos_db: '#/components/schemas/AzureCosmosDBChatDataSource' + elasticsearch: '#/components/schemas/ElasticsearchChatDataSource' + pinecone: '#/components/schemas/PineconeChatDataSource' + mongo_db: '#/components/schemas/MongoDBChatDataSource' + description: |- + A representation of configuration data for a single Azure OpenAI chat data source. + This will be used by a chat completions request that should use Azure OpenAI chat extensions to augment the + response behavior. + The use of this configuration is compatible only with Azure OpenAI. + AzureChatDataSourceAccessTokenAuthenticationOptions: + type: object + required: + - type + - access_token + properties: + type: + type: string + enum: + - access_token + access_token: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceApiKeyAuthenticationOptions: + type: object + required: + - type + - key + properties: + type: + type: string + enum: + - api_key + key: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceAuthenticationOptions: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' + connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' + encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' + access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + AzureChatDataSourceConnectionStringAuthenticationOptions: + type: object + required: + - type + - connection_string + properties: + type: + type: string + enum: + - connection_string + connection_string: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceDeploymentNameVectorizationSource: + type: object + required: + - type + - deployment_name + properties: + type: + type: string + enum: + - deployment_name + description: The type identifier, always 'deployment_name' for this vectorization source type. + deployment_name: + type: string + description: |- + The embedding model deployment to use for vectorization. This deployment must exist within the same Azure OpenAI + resource as the model deployment being used for chat completions. + dimensions: + type: integer + format: int32 + description: |- + The number of dimensions to request on embeddings. + Only supported in 'text-embedding-3' and later models. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: |- + Represents a vectorization source that makes internal service calls against an Azure OpenAI embedding model + deployment. In contrast with the endpoint-based vectorization source, a deployment-name-based vectorization source + must be part of the same Azure OpenAI resource but can be used even in private networks. + AzureChatDataSourceEncodedApiKeyAuthenticationOptions: + type: object + required: + - type + - encoded_api_key + properties: + type: + type: string + enum: + - encoded_api_key + encoded_api_key: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceEndpointVectorizationSource: + type: object + required: + - type + - endpoint + - authentication + properties: + type: + type: string + enum: + - endpoint + description: The type identifier, always 'endpoint' for this vectorization source type. + endpoint: + type: string + format: uri + description: |- + Specifies the resource endpoint URL from which embeddings should be retrieved. + It should be in the format of: + https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. + The api-version query parameter is not allowed. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: |- + The authentication mechanism to use with the endpoint-based vectorization source. + Endpoint authentication supports API key and access token mechanisms. + dimensions: + type: integer + format: int32 + description: |- + The number of dimensions to request on embeddings. + Only supported in 'text-embedding-3' and later models. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: Represents a vectorization source that makes public service calls against an Azure OpenAI embedding model deployment. + AzureChatDataSourceIntegratedVectorizationSource: + type: object + required: + - type + properties: + type: + type: string + enum: + - integrated + description: The type identifier, always 'integrated' for this vectorization source type. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: Represents an integrated vectorization source as defined within the supporting search resource. + AzureChatDataSourceKeyAndKeyIdAuthenticationOptions: + type: object + required: + - type + - key + - key_id + properties: + type: + type: string + enum: + - key_and_key_id + key: + type: string + key_id: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceModelIdVectorizationSource: + type: object + required: + - type + - model_id + properties: + type: + type: string + enum: + - model_id + description: The type identifier, always 'model_id' for this vectorization source type. + model_id: + type: string + description: The embedding model build ID to use for vectorization. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: |- + Represents a vectorization source that makes service calls based on a search service model ID. + This source type is currently only supported by Elasticsearch. + AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions: + type: object + required: + - type + properties: + type: + type: string + enum: + - system_assigned_managed_identity + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions: + type: object + required: + - type + - managed_identity_resource_id + properties: + type: + type: string + enum: + - user_assigned_managed_identity + managed_identity_resource_id: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceUsernameAndPasswordAuthenticationOptions: + type: object + required: + - type + - username + - password + properties: + type: + type: string + enum: + - username_and_password + username: + type: string + password: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceVectorizationSource: + type: object + required: + - type + properties: + type: + type: string + description: The differentiating identifier for the concrete vectorization source. + discriminator: + propertyName: type + mapping: + deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' + integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: A representation of a data vectorization source usable as an embedding resource with a data source. + AzureChatMessageContext: + type: object + properties: + intent: + type: string + description: The detected intent from the chat history, which is used to carry conversation context between interactions + citations: + type: array + items: + type: object + properties: + content: + type: string + description: The content of the citation. + title: + type: string + description: The title for the citation. + url: + type: string + description: The URL of the citation. + filepath: + type: string + description: The file path for the citation. + chunk_id: + type: string + description: The chunk ID for the citation. + rerank_score: + type: number + format: double + description: The rerank score for the retrieval. + required: + - content + description: The citations produced by the data retrieval. + all_retrieved_documents: + type: object + properties: + content: + type: string + description: The content of the citation. + title: + type: string + description: The title for the citation. + url: + type: string + description: The URL of the citation. + filepath: + type: string + description: The file path for the citation. + chunk_id: + type: string + description: The chunk ID for the citation. + rerank_score: + type: number + format: double + description: The rerank score for the retrieval. + search_queries: + type: array + items: + type: string + description: The search queries executed to retrieve documents. + data_source_index: + type: integer + format: int32 + description: The index of the data source used for retrieval. + original_search_score: + type: number + format: double + description: The original search score for the retrieval. + filter_reason: + type: string + enum: + - score + - rerank + description: If applicable, an indication of why the document was filtered. + required: + - content + - search_queries + - data_source_index + description: Summary information about documents retrieved by the data retrieval operation. + description: |- + An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using + extension behavior. This includes intent and citation information from the On Your Data feature. + AzureContentFilterBlocklistIdResult: + type: object + required: + - id + - filtered + properties: + id: + type: string + description: The ID of the custom blocklist associated with the filtered status. + filtered: + type: boolean + description: Whether the associated blocklist resulted in the content being filtered. + description: |- + A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not + the corresponding blocklist resulted in content being filtered. + AzureContentFilterBlocklistResult: + type: object + required: + - filtered + properties: + filtered: + type: boolean + description: A value indicating whether any of the detailed blocklists resulted in a filtering action. + details: + type: array + items: + type: object + properties: + filtered: + type: boolean + description: A value indicating whether the blocklist produced a filtering action. + id: + type: string + description: The ID of the custom blocklist evaluated. + required: + - filtered + - id + description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. + description: A collection of true/false filtering results for configured custom blocklists. + AzureContentFilterCompletionTextSpan: + type: object + required: + - completion_start_offset + - completion_end_offset + properties: + completion_start_offset: + type: integer + format: int32 + description: Offset of the UTF32 code point which begins the span. + completion_end_offset: + type: integer + format: int32 + description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. + description: A representation of a span of completion text as used by Azure OpenAI content filter results. + AzureContentFilterCompletionTextSpanDetectionResult: + type: object + required: + - filtered + - detected + - details + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + details: + type: array + items: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' + description: Detailed information about the detected completion text spans. + AzureContentFilterDetectionResult: + type: object + required: + - filtered + - detected + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + description: |- + A labeled content filter result item that indicates whether the content was detected and whether the content was + filtered. + AzureContentFilterImagePromptResults: + type: object + required: + - jailbreak + properties: + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + jailbreak: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that describes user prompt injection attacks, where malicious users deliberately exploit + system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content + generation or violations of system-imposed restrictions. + allOf: + - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + description: A content filter result for an image generation operation's input request content. + AzureContentFilterImageResponseResults: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + ungrounded_material: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' + description: A content filter result for a single response item produced by a generative AI system. + AzureContentFilterResultForPrompt: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt associated with the accompanying content filter result categories. + content_filter_results: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + jailbreak: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that describes user prompt injection attacks, where malicious users deliberately exploit + system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content + generation or violations of system-imposed restrictions. + indirect_attack: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that describes attacks on systems powered by Generative AI models that can happen every time + an application processes information that wasn’t directly authored by either the developer of the application or + the user. + required: + - jailbreak + - indirect_attack + description: The content filter category details for the result. + description: A content filter result associated with a single input prompt item into a generative AI system. + AzureContentFilterSeverityResult: + type: object + required: + - filtered + - severity + properties: + filtered: + type: boolean + description: Whether the content severity resulted in a content filtering action. + severity: + type: string + enum: + - safe + - low + - medium + - high + description: The labeled severity of the content. + description: |- + A labeled content filter result item that indicates whether the content was filtered and what the qualitative + severity level of the content was, as evaluated against content filter configuration for the category. + AzureCosmosDBChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_cosmos_db + description: The discriminated type identifier, which is always 'azure_cosmos_db'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + container_name: + type: string + database_name: + type: string + embedding_dependency: + $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + index_name: + type: string + authentication: + $ref: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + fields_mapping: + type: object + properties: + content_fields: + type: array + items: + type: string + vector_fields: + type: array + items: + type: string + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields_separator: + type: string + required: + - content_fields + - vector_fields + required: + - container_name + - database_name + - embedding_dependency + - index_name + - authentication + - fields_mapping + description: The parameter information to control the use of the Azure CosmosDB data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure CosmosDB resource. + AzureCreateChatCompletionRequest: + type: object + properties: + data_sources: + type: array + items: + $ref: '#/components/schemas/AzureChatDataSource' + description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. + user_security_context: + $ref: '#/components/schemas/AzureUserSecurityContext' + allOf: + - $ref: '#/components/schemas/OpenAI.CreateChatCompletionRequest' + description: |- + The extended request model for chat completions against the Azure OpenAI service. + This adds the ability to provide data sources for the On Your Data feature. + AzureCreateChatCompletionResponse: + type: object + properties: + prompt_filter_results: + type: array + items: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt that this content filter result corresponds to. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter results associated with the indexed input prompt. + required: + - prompt_index + - content_filter_results + description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. + allOf: + - $ref: '#/components/schemas/OpenAI.CreateChatCompletionResponse' + description: |- + The extended top-level chat completion response model for the Azure OpenAI service. + This model adds Responsible AI content filter annotations for prompt input. + AzureImage: + type: object + required: + - prompt_filter_results + - content_filter_results + properties: + prompt_filter_results: + $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + content_filter_results: + $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + allOf: + - $ref: '#/components/schemas/OpenAI.Image' + AzureOpenAIChatError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI chat completion request. + AzureOpenAIChatErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIChatError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIDalleError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI image generation request. + AzureOpenAIDalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIDalleError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIFile: + type: object + required: + - id + - bytes + - created_at + - filename + - object + - purpose + - status + properties: + id: + type: string + description: The file identifier, which can be referenced in the API endpoints. + bytes: + type: integer + format: int32 + nullable: true + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + filename: + type: string + description: The name of the file. + object: + type: string + enum: + - file + description: The object type, which is always `file`. + purpose: + type: string + enum: + - assistants + - assistants_output + - batch + - batch_output + - fine-tune + - fine-tune-results + - vision + description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. + status_details: + type: string + description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + deprecated: true + status: + type: string + enum: + - uploaded + - pending + - running + - processed + - error + - deleting + - deleted + AzureOpenAIServiceApiVersion: + type: string + enum: + - 2024-06-01 + - 2024-08-01-preview + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 + - 2024-12-01-preview + description: Known service API versions for Azure OpenAI. + AzureSearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_search + description: The discriminated type identifier, which is always 'azure_search'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + description: The absolute endpoint path for the Azure Search resource to use. + index_name: + type: string + description: The name of the index to use, as specified in the Azure Search resource. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: The authentication mechanism to use with Azure Search. + fields_mapping: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + items: + type: string + description: The names of index fields that should be treated as content. + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + items: + type: string + description: The names of fields that represent vector data. + image_vector_fields: + type: array + items: + type: string + description: The names of fields that represent image vector data. + description: The field mappings to use with the Azure Search resource. + query_type: + type: string + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: + type: string + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + AzureUserSecurityContext: + type: object + properties: + application_name: + type: string + description: The name of the application. Sensitive personal information should not be included in this field. + end_user_id: + type: string + description: This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. + end_user_tenant_id: + type: string + description: The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. + source_ip: + type: string + description: Captures the original client's IP address. + description: User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionTokenLogprobBytes: + type: array + items: + type: integer + format: int32 + CreateMessageRequestAttachments: + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools + ElasticsearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - elasticsearch + description: The discriminated type identifier, which is always 'elasticsearch'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + index_name: + type: string + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' + fields_mapping: + type: object + properties: + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields: + type: array + items: + type: string + content_fields_separator: + type: string + vector_fields: + type: array + items: + type: string + query_type: + type: string + enum: + - simple + - vector + embedding_dependency: + $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Elasticsearch data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + MessageObjectAttachments: + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + MongoDBChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - mongo_db + description: The discriminated type identifier, which is always 'mongo_db'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + description: The name of the MongoDB cluster endpoint. + database_name: + type: string + description: The name of the MongoDB database. + collection_name: + type: string + description: The name of the MongoDB collection. + app_name: + type: string + description: The name of the MongoDB application. + index_name: + type: string + description: The name of the MongoDB index. + authentication: + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' + description: |- + The authentication mechanism to use with Pinecone. + Supported authentication mechanisms for Pinecone include: username and password. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + description: |- + The vectorization source to use as an embedding dependency for the MongoDB data source. + Supported vectorization sources for MongoDB include: endpoint, deployment name. + fields_mapping: + type: object + properties: + content_fields: + type: array + items: + type: string + vector_fields: + type: array + items: + type: string + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields_separator: + type: string + required: + - content_fields + - vector_fields + description: |- + Field mappings to apply to data used by the MongoDB data source. + Note that content and vector field mappings are required for MongoDB. + required: + - endpoint + - database_name + - collection_name + - app_name + - index_name + - authentication + - embedding_dependency + - fields_mapping + description: The parameter information to control the use of the MongoDB data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + OpenAI.AssistantToolDefinition: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + file_search: '#/components/schemas/OpenAI.AssistantToolsFileSearch' + function: '#/components/schemas/OpenAI.AssistantToolsFunction' + OpenAI.AssistantToolsCode: + type: object + required: + - type + properties: + type: + type: string + enum: + - code_interpreter + description: 'The type of tool being defined: `code_interpreter`' + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.AssistantToolsFileSearch: + type: object + required: + - type + properties: + type: + type: string + enum: + - file_search + description: 'The type of tool being defined: `file_search`' + file_search: + type: object + properties: + max_num_results: + type: integer + format: int32 + minimum: 1 + maximum: 50 + description: |- + The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + ranking_options: + $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' + description: Overrides for the file search tool. + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.AssistantToolsFileSearchTypeOnly: + type: object + required: + - type + properties: + type: + type: string + enum: + - file_search + description: 'The type of tool being defined: `file_search`' + OpenAI.AssistantToolsFunction: + type: object + required: + - type + - function + properties: + type: + type: string + enum: + - function + description: 'The type of tool being defined: `function`' + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.ChatCompletionFunctionCallOption: + type: object + required: + - name + properties: + name: + type: string + description: The name of the function to call. + description: 'Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.' + OpenAI.ChatCompletionFunctions: + type: object + required: + - name + properties: + description: + type: string + description: A description of what the function does, used by the model to choose when and how to call the function. + name: + type: string + description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/OpenAI.FunctionParameters' + deprecated: true + OpenAI.ChatCompletionMessageToolCall: + type: object + required: + - id + - type + - function + properties: + id: + type: string + description: The ID of the tool call. + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + arguments: + type: string + description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. + required: + - name + - arguments + description: The function that the model called. + OpenAI.ChatCompletionMessageToolCallChunk: + type: object + required: + - index + properties: + index: + type: integer + format: int32 + id: + type: string + description: The ID of the tool call. + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + arguments: + type: string + description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. + OpenAI.ChatCompletionNamedToolChoice: + type: object + required: + - type + - function + properties: + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + required: + - name + description: Specifies a tool the model should use. Use to force the model to call a specific function. + OpenAI.ChatCompletionRequestAssistantMessage: + type: object + required: + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessageContentPart' + nullable: true + description: The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. + x-oaiExpandable: true + refusal: + type: string + nullable: true + description: The refusal message by the assistant. + role: + type: string + enum: + - assistant + description: The role of the messages author, in this case `assistant`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + nullable: true + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestAssistantMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestFunctionMessage: + type: object + required: + - role + - content + - name + properties: + role: + type: string + enum: + - function + description: The role of the messages author, in this case `function`. + content: + type: string + nullable: true + description: The contents of the function message. + name: + type: string + description: The name of the function to call. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + deprecated: true + OpenAI.ChatCompletionRequestMessage: + type: object + required: + - role + properties: + role: + type: string + description: The role of the author of this message. + discriminator: + propertyName: role + mapping: + system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' + assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' + tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' + function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartImage: + type: object + required: + - type + - image_url + properties: + type: + type: string + enum: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: Either a URL of the image or the base64 encoded image data. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + default: auto + required: + - url + OpenAI.ChatCompletionRequestMessageContentPartRefusal: + type: object + required: + - type + - refusal + properties: + type: + type: string + enum: + - refusal + description: The type of the content part. + refusal: + type: string + description: The refusal message generated by the model. + OpenAI.ChatCompletionRequestMessageContentPartText: + type: object + required: + - type + - text + properties: + type: + type: string + enum: + - text + description: The type of the content part. + text: + type: string + description: The text content. + OpenAI.ChatCompletionRequestSystemMessage: + type: object + required: + - content + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + description: The contents of the system message. + role: + type: string + enum: + - system + description: The role of the messages author, in this case `system`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestSystemMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestToolMessage: + type: object + required: + - role + - content + - tool_call_id + properties: + role: + type: string + enum: + - tool + description: The role of the messages author, in this case `tool`. + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' + description: The contents of the tool message. + tool_call_id: + type: string + description: Tool call that this message is responding to. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestToolMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestUserMessage: + type: object + required: + - content + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' + description: The contents of the user message. + x-oaiExpandable: true + role: + type: string + enum: + - user + description: The role of the messages author, in this case `user`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestUserMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + x-oaiExpandable: true + OpenAI.ChatCompletionResponseMessage: + type: object + required: + - content + - refusal + - role + properties: + content: + type: string + nullable: true + description: The contents of the message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + role: + type: string + enum: + - assistant + description: The role of the author of this message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + description: A chat completion message generated by the model. + OpenAI.ChatCompletionStreamOptions: + type: object + properties: + include_usage: + type: boolean + description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' + description: 'Options for streaming response. Only set this when you set `stream: true`.' + OpenAI.ChatCompletionStreamResponseDelta: + type: object + properties: + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + description: A chat completion delta generated by streamed model responses. + OpenAI.ChatCompletionTokenLogprob: + type: object + required: + - token + - logprob + - bytes + - top_logprobs + properties: + token: + type: string + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + top_logprobs: + type: array + items: + type: object + properties: + token: + type: string + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: array + items: + type: integer + format: int32 + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + required: + - token + - logprob + - bytes + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + OpenAI.ChatCompletionTool: + type: object + required: + - type + - function + properties: + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + OpenAI.ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - auto + - required + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' + description: |- + Controls which (if any) tool is called by the model. + `none` means the model will not call any tool and instead generates a message. + `auto` means the model can pick between generating a message or calling one or more tools. + `required` means the model must call one or more tools. + Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + + `none` is the default when no tools are present. `auto` is the default if tools are present. + x-oaiExpandable: true + OpenAI.ChatResponseFormat: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/OpenAI.ChatResponseFormatText' + json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' + json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' + OpenAI.ChatResponseFormatJsonObject: + type: object + required: + - type + properties: + type: + type: string + enum: + - json_object + description: 'The type of response format being defined: `json_object`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatJsonSchema: + type: object + required: + - type + - json_schema + properties: + type: + type: string + enum: + - json_schema + description: 'The type of response format being defined: `json_schema`' + json_schema: + type: object + properties: + description: + type: string + description: A description of what the response format is for, used by the model to determine how to respond in the format. + name: + type: string + description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + default: false + required: + - name + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatText: + type: object + required: + - type + properties: + type: + type: string + enum: + - text + description: 'The type of response format being defined: `text`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + audio_tokens: + type: integer + format: int32 + description: Audio input tokens generated by the model. + reasoning_tokens: + type: integer + format: int32 + description: Tokens generated by the model for reasoning. + required: + - audio_tokens + - reasoning_tokens + description: Breakdown of tokens used in a completion. + prompt_tokens_details: + type: object + properties: + audio_tokens: + type: integer + format: int32 + description: Audio input tokens present in the prompt. + cached_tokens: + type: integer + format: int32 + description: Cached tokens present in the prompt. + required: + - audio_tokens + - cached_tokens + description: Breakdown of tokens used in the prompt. + description: Usage statistics for the completion request. + OpenAI.CreateChatCompletionRequest: + type: object + required: + - messages + - model + properties: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + model: + anyOf: + - type: string + - type: string + enum: + - o1-preview + - o1-preview-2024-09-12 + - o1-mini + - o1-mini-2024-09-12 + - gpt-4o + - gpt-4o-2024-08-06 + - gpt-4o-2024-05-13 + - gpt-4o-realtime-preview + - gpt-4o-realtime-preview-2024-10-01 + - chatgpt-4o-latest + - gpt-4o-mini + - gpt-4o-mini-2024-07-18 + - gpt-4-turbo + - gpt-4-turbo-2024-04-09 + - gpt-4-0125-preview + - gpt-4-turbo-preview + - gpt-4-1106-preview + - gpt-4-vision-preview + - gpt-4 + - gpt-4-0314 + - gpt-4-0613 + - gpt-4-32k + - gpt-4-32k-0314 + - gpt-4-32k-0613 + - gpt-3.5-turbo + - gpt-3.5-turbo-16k + - gpt-3.5-turbo-0301 + - gpt-3.5-turbo-0613 + - gpt-3.5-turbo-1106 + - gpt-3.5-turbo-0125 + - gpt-3.5-turbo-16k-0613 + description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. + x-oaiTypeLabel: string + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + service_tier: + type: string + enum: + - auto + - default + nullable: true + description: |- + Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: + - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. + - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + - When not set, the default behavior is 'auto'. + + When this parameter is set, the response body will include the `service_tier` utilized. + default: auto + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + OpenAI.CreateChatCompletionResponse: + type: object + required: + - id + - choices + - created + - model + - object + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + usage: + $ref: '#/components/schemas/OpenAI.CompletionUsage' + description: Represents a chat completion response returned by model, based on the provided input. + OpenAI.CreateImageRequest: + type: object + required: + - prompt + properties: + prompt: + type: string + description: A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`. + model: + anyOf: + - type: string + - type: string + enum: + - dall-e-2 + - dall-e-3 + nullable: true + description: The model to use for image generation. + x-oaiTypeLabel: string + default: dall-e-2 + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 10 + description: The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported. + default: 1 + quality: + type: string + enum: + - standard + - hd + description: The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`. + default: standard + response_format: + type: string + enum: + - url + - b64_json + nullable: true + description: The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. + default: url + size: + type: string + enum: + - 256x256 + - 512x512 + - 1024x1024 + - 1792x1024 + - 1024x1792 + nullable: true + description: The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3` models. + default: 1024x1024 + style: + type: string + enum: + - vivid + - natural + nullable: true + description: The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`. + default: vivid + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + OpenAI.CreateMessageRequest: + type: object + required: + - role + - content + properties: + role: + type: string + enum: + - user + - assistant + description: |- + The role of the entity that is creating the message. Allowed values include: + - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. + - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContent' + x-oaiExpandable: true + attachments: + type: object + allOf: + - $ref: '#/components/schemas/CreateMessageRequestAttachments' + nullable: true + description: A list of files attached to the message, and the tools they should be added to. + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + x-oaiTypeLabel: map + OpenAI.Error: + type: object + required: + - code + - message + - param + - type + properties: + code: + type: string + nullable: true + message: + type: string + param: + type: string + nullable: true + type: + type: string + OpenAI.ErrorResponse: + type: object + required: + - error + properties: + error: + $ref: '#/components/schemas/OpenAI.Error' + OpenAI.FileSearchRankingOptions: + type: object + required: + - score_threshold + properties: + ranker: + type: string + enum: + - auto + - default_2024_08_21 + description: The ranker to use for the file search. If not specified will use the `auto` ranker. + score_threshold: + type: number + format: float + minimum: 0 + maximum: 1 + description: The score threshold for the file search. All values must be a floating point number between 0 and 1. + description: |- + The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + + See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + OpenAI.FunctionObject: + type: object + required: + - name + properties: + description: + type: string + description: A description of what the function does, used by the model to choose when and how to call the function. + name: + type: string + description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/OpenAI.FunctionParameters' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling). + default: false + OpenAI.FunctionParameters: + type: object + additionalProperties: {} + description: |- + The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + + Omitting `parameters` defines a function with an empty parameter list. + OpenAI.Image: + type: object + properties: + b64_json: + type: string + format: base64 + description: The base64-encoded JSON of the generated image, if `response_format` is `b64_json`. + url: + type: string + format: uri + description: The URL of the generated image, if `response_format` is `url` (default). + revised_prompt: + type: string + description: The prompt that was used to generate the image, if there was any revision to the prompt. + description: Represents the url or the content of an image generated by the OpenAI API. + OpenAI.ImagesResponse: + type: object + required: + - created + - data + properties: + created: + type: integer + format: unixtime + data: + type: array + items: + $ref: '#/components/schemas/OpenAI.Image' + OpenAI.MessageContent: + type: object + description: Represents a single piece of content in an Assistants API message. + OpenAI.MessageContentImageFileObject: + type: object + required: + - type + - image_file + properties: + type: + type: string + enum: + - image_file + description: Always `image_file`. + image_file: + type: object + properties: + file_id: + type: string + description: The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. + default: auto + required: + - file_id + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: References an image [File](/docs/api-reference/files) in the content of a message. + OpenAI.MessageContentImageUrlObject: + type: object + required: + - type + - image_url + properties: + type: + type: string + enum: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: 'The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.' + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + default: auto + required: + - url + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: References an image URL in the content of a message. + OpenAI.MessageContentRefusalObject: + type: object + required: + - type + - refusal + properties: + type: + type: string + enum: + - refusal + description: Always `refusal`. + refusal: + type: string + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The refusal content generated by the assistant. + OpenAI.MessageContentTextAnnotationsFileCitationObject: + type: object + required: + - type + - text + - file_citation + - start_index + - end_index + properties: + type: + type: string + enum: + - file_citation + description: Always `file_citation`. + text: + type: string + description: The text in the message content that needs to be replaced. + file_citation: + type: object + properties: + file_id: + type: string + description: The ID of the specific File the citation is from. + required: + - file_id + start_index: + type: integer + format: int32 + minimum: 0 + end_index: + type: integer + format: int32 + minimum: 0 + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + description: A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + OpenAI.MessageContentTextAnnotationsFilePathObject: + type: object + required: + - type + - text + - file_path + - start_index + - end_index + properties: + type: + type: string + enum: + - file_path + description: Always `file_path`. + text: + type: string + description: The text in the message content that needs to be replaced. + file_path: + type: object + properties: + file_id: + type: string + description: The ID of the file that was generated. + required: + - file_id + start_index: + type: integer + format: int32 + minimum: 0 + end_index: + type: integer + format: int32 + minimum: 0 + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + description: A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + OpenAI.MessageContentTextObject: + type: object + required: + - type + - text + properties: + type: + type: string + enum: + - text + description: Always `text`. + text: + type: object + properties: + value: + type: string + description: The data that makes up the text. + annotations: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + x-oaiExpandable: true + required: + - value + - annotations + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The text content that is part of a message. + OpenAI.MessageContentTextObjectAnnotation: + type: object + required: + - type + properties: + type: + type: string + description: The discriminated type identifier for the content item. + discriminator: + propertyName: type + mapping: + file_citation: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFileCitationObject' + file_path: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFilePathObject' + OpenAI.MessageObject: + type: object + required: + - id + - object + - created_at + - thread_id + - status + - incomplete_details + - completed_at + - incomplete_at + - role + - content + - assistant_id + - run_id + - attachments + - metadata + properties: + id: + type: string + description: The identifier, which can be referenced in API endpoints. + object: + type: string + enum: + - thread.message + description: The object type, which is always `thread.message`. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the message was created. + thread_id: + type: string + description: The [thread](/docs/api-reference/threads) ID that this message belongs to. + status: + type: string + enum: + - in_progress + - incomplete + - completed + description: The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + incomplete_details: + type: object + properties: + reason: + type: string + enum: + - content_filter + - max_tokens + - run_cancelled + - run_expired + - run_failed + description: The reason the message is incomplete. + required: + - reason + nullable: true + description: On an incomplete message, details about why the message is incomplete. + completed_at: + type: integer + format: unixtime + nullable: true + description: The Unix timestamp (in seconds) for when the message was completed. + incomplete_at: + type: integer + format: unixtime + nullable: true + description: The Unix timestamp (in seconds) for when the message was marked as incomplete. + role: + type: string + enum: + - user + - assistant + description: The entity that produced the message. One of `user` or `assistant`. + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContent' + description: The content of the message in array of text and/or images. + x-oaiExpandable: true + readOnly: true + assistant_id: + type: string + nullable: true + description: If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. + run_id: + type: string + nullable: true + description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. + attachments: + type: object + allOf: + - $ref: '#/components/schemas/MessageObjectAttachments' + nullable: true + description: A list of files attached to the message, and the tools they were added to. + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + x-oaiTypeLabel: map + readOnly: true + description: Represents a message within a [thread](/docs/api-reference/threads). + OpenAI.MessageRequestContentTextObject: + type: object + required: + - type + - text + properties: + type: + type: string + enum: + - text + description: Always `text`. + text: + type: string + description: Text content to be sent to the model + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The text content that is part of a message. + OpenAI.ResponseFormatJsonSchemaSchema: + type: object + additionalProperties: {} + description: The schema for the response format, described as a JSON Schema object. + OpenAIFileWithOmittedProperties: + type: object + required: + - id + - bytes + - created_at + - filename + - object + - purpose + properties: + id: + type: string + description: The file identifier, which can be referenced in the API endpoints. + bytes: + type: integer + format: int32 + nullable: true + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + filename: + type: string + description: The name of the file. + object: + type: string + enum: + - file + description: The object type, which is always `file`. + purpose: + type: string + enum: + - assistants + - assistants_output + - batch + - batch_output + - fine-tune + - fine-tune-results + - vision + description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. + status_details: + type: string + description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + deprecated: true + description: The `File` object represents a document that has been uploaded to OpenAI. + PineconeChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - pinecone + description: The discriminated type identifier, which is always 'pinecone'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + environment: + type: string + description: The environment name to use with Pinecone. + index_name: + type: string + description: The name of the Pinecone database index to use. + authentication: + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + description: |- + The authentication mechanism to use with Pinecone. + Supported authentication mechanisms for Pinecone include: API key. + embedding_dependency: + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: |- + The vectorization source to use as an embedding dependency for the Pinecone data source. + Supported vectorization sources for Pinecone include: deployment name. + fields_mapping: + type: object + properties: + content_fields: + type: array + items: + type: string + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields_separator: + type: string + required: + - content_fields + description: |- + Field mappings to apply to data used by the Pinecone data source. + Note that content field mappings are required for Pinecone. + required: + - environment + - index_name + - authentication + - embedding_dependency + - fields_mapping + description: The parameter information to control the use of the Pinecone data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + securitySchemes: + ApiKeyAuth: + type: apiKey + in: header + name: api-key + OAuth2Auth: + type: oauth2 + flows: + implicit: + authorizationUrl: https://login.microsoftonline.com/common/oauth2/v2.0/authorize + scopes: + https://cognitiveservices.azure.com/.default: '' +servers: + - url: '{endpoint}/openai' + description: Azure OpenAI APIs for completions and search + variables: + endpoint: + default: '' + description: |- + Supported Cognitive Services endpoints (protocol and hostname, for example: + https://westus.api.cognitive.microsoft.com). diff --git a/.typespec.azure/chat/models.request.tsp b/.typespec.azure/chat/models.request.tsp index 2d9ba381a..f4e7b4c81 100644 --- a/.typespec.azure/chat/models.request.tsp +++ b/.typespec.azure/chat/models.request.tsp @@ -19,6 +19,9 @@ model AzureCreateChatCompletionRequest * The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. */ data_sources?: AzureChatDataSource[]; + + @added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) + user_security_context?: AzureUserSecurityContext; } /** @@ -316,3 +319,21 @@ alias AzureChatDataSourceCommonParameters = { "intent" ]; }; + +/** + * User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. + */ +@added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) +model AzureUserSecurityContext { + /** The name of the application. Sensitive personal information should not be included in this field. */ + application_name?: string; + + /** This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. */ + end_user_id?: string; + + /** The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. */ + end_user_tenant_id?: string; + + /** Captures the original client's IP address. */ + source_ip?: string; +} diff --git a/.typespec.azure/common/models.rai.tsp b/.typespec.azure/common/models.rai.tsp index a8068a3aa..e53940458 100644 --- a/.typespec.azure/common/models.rai.tsp +++ b/.typespec.azure/common/models.rai.tsp @@ -59,6 +59,7 @@ model AzureContentFilterCompletionTextSpan { @added(AzureOpenAIServiceApiVersion.v2024_10_01_preview) @removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) model AzureContentFilterCompletionTextSpanDetectionResult { ...AzureContentFilterDetectionResult; @@ -67,6 +68,7 @@ model AzureContentFilterCompletionTextSpanDetectionResult { */ @added(AzureOpenAIServiceApiVersion.v2024_10_01_preview) @removed(AzureOpenAIServiceApiVersion.v2024_10_21) + @added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) details: AzureContentFilterCompletionTextSpan[]; } @@ -171,6 +173,7 @@ model AzureContentFilterResultForChoice { @added(AzureOpenAIServiceApiVersion.v2024_10_01_preview) @removed(AzureOpenAIServiceApiVersion.v2024_10_21) + @added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) ungrounded_material?: AzureContentFilterCompletionTextSpanDetectionResult; } diff --git a/.typespec.azure/main.tsp b/.typespec.azure/main.tsp index 54310a2ab..ef9223a44 100644 --- a/.typespec.azure/main.tsp +++ b/.typespec.azure/main.tsp @@ -76,4 +76,9 @@ enum AzureOpenAIServiceApiVersion { * The 2024-10-21 (stable) service API version label. */ v2024_10_21: "2024-10-21", + + /** + * The 2024-12-01-preview service API version label. + */ + v2024_12_01_Preview: "2024-12-01-preview", } From 3c540dc6f3560eefa60fff18bf5423bf692fa8eb Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 15 Jan 2025 17:17:19 -0800 Subject: [PATCH 05/44] desquished complete --- .dotnet/CHANGELOG.md | 8 +- .dotnet/README.md | 23 ++- .dotnet/api/OpenAI.netstandard2.0.cs | 30 +++- .../examples/Chat/Example09_ChatWithAudio.cs | 20 +-- .../Chat/Example10_ChatWithAudioAsync.cs | 20 +-- .../AssistantChatMessage.Serialization.cs | 124 +-------------- .../src/Custom/Chat/AssistantChatMessage.cs | 18 ++- .dotnet/src/Custom/Chat/ChatCompletion.cs | 20 +-- .dotnet/src/Custom/Chat/ChatMessage.cs | 13 +- .../ChatMessageContentPart.Serialization.cs | 9 +- .../src/Custom/Chat/ChatMessageContentPart.cs | 89 +---------- .dotnet/src/Custom/Chat/ChatResponseAudio.cs | 11 ++ .../Custom/Chat/ChatResponseAudioReference.cs | 10 ++ .../Custom/Chat/Internal/GeneratorStubs.cs | 6 - ...ternalChatCompletionStreamResponseDelta.cs | 5 + .../src/Custom/Chat/OpenAIChatModelFactory.cs | 37 ++--- .../StreamingChatCompletionUpdate.cs | 20 +-- .../AssistantChatMessage.Serialization.cs | 105 ++++++++++++- .../Generated/Models/AssistantChatMessage.cs | 4 +- ....cs => ChatResponseAudio.Serialization.cs} | 52 +++---- ...seMessageAudio.cs => ChatResponseAudio.cs} | 6 +- ...hatResponseAudioReference.Serialization.cs | 145 ++++++++++++++++++ ...Audio.cs => ChatResponseAudioReference.cs} | 6 +- ...uestAssistantMessageAudio.Serialization.cs | 145 ------------------ ...CompletionResponseMessage.Serialization.cs | 4 +- .../InternalChatCompletionResponseMessage.cs | 4 +- ...letionStreamResponseDelta.Serialization.cs | 32 ++-- ...ternalChatCompletionStreamResponseDelta.cs | 6 +- ...onRequestAssistantMessage.Serialization.cs | 8 +- ...neChatCompletionRequestAssistantMessage.cs | 2 +- .dotnet/src/Generated/OpenAIModelFactory.cs | 21 ++- .dotnet/tests/Chat/ChatSmokeTests.cs | 33 ++-- .dotnet/tests/Chat/ChatTests.cs | 40 ++--- .scripts/Edit-Serialization.ps1 | 36 ++++- 34 files changed, 517 insertions(+), 595 deletions(-) create mode 100644 .dotnet/src/Custom/Chat/ChatResponseAudio.cs create mode 100644 .dotnet/src/Custom/Chat/ChatResponseAudioReference.cs rename .dotnet/src/Generated/Models/{InternalChatCompletionResponseMessageAudio.Serialization.cs => ChatResponseAudio.Serialization.cs} (59%) rename .dotnet/src/Generated/Models/{InternalChatCompletionResponseMessageAudio.cs => ChatResponseAudio.cs} (70%) create mode 100644 .dotnet/src/Generated/Models/ChatResponseAudioReference.Serialization.cs rename .dotnet/src/Generated/Models/{InternalChatCompletionRequestAssistantMessageAudio.cs => ChatResponseAudioReference.cs} (69%) delete mode 100644 .dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.Serialization.cs diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index 47879fd8b..1d88ffe18 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -6,11 +6,9 @@ - Chat completion now supports audio input and output! - To configure a chat completion to request audio output using the `gpt-4o-audio-preview` model, create a `ChatAudioOptions` instance and provide it on `ChatCompletionOptions.AudioOptions`. - - Audio is always represented as a `ChatMessageContentPart`: - - User audio input can be instantiated via `ChatMessageContentPart.CreateAudioPart(BinaryData, ChatAudioInputFormat)` and will populate the `AudioBytes` and `AudioInputFormat` properties on `ChatMessageContentPart` - - Response audio associated with the items in `Content` of a `ChatCompletion` or `ContentUpdate` of a `StreamingChatCompletionUpdate` will populate the `AudioBytes`, `AudioTranscript`, `AudioExpiresAt`, and `AudioCorrelationId` properties - - Audio referring to a previous response's output can be created via `ChatMessageContentPart.CreateAudioPart(string)` and will populate the `AudioCorrelationId` property. - - The `AssistantChatMessage(IEnumerable)` and `AssistantChatMessage(ChatCompletion)` constructors will automatically infer `AudioCorrelationId`, simplifying conversation history management + - Input chat audio is provided to `UserChatMessage` instances using `ChatContentPart.CreateInputAudioPart()` + - Output chat audio is provided on the `ResponseAudio` property of `ChatCompletion` + - References to prior assistant audio are provided via `ResponseAudioReference` instances on the `AudioReference` property of `AssistantChatMessage`; `AssistantChatMessage(chatCompletion)` will automatically handle this, too - For more information, see the example in the README ## 2.1.0 (2024-12-04) diff --git a/.dotnet/README.md b/.dotnet/README.md index d0d710937..122070d2c 100644 --- a/.dotnet/README.md +++ b/.dotnet/README.md @@ -389,28 +389,23 @@ ChatCompletion completion = client.CompleteChat(messages, options); void PrintAudioContent() { - foreach (ChatMessageContentPart contentPart in completion.Content) + if (completion.ResponseAudio is ChatResponseAudio responseAudio) { - if (contentPart.AudioCorrelationId is not null) + Console.WriteLine($"Response audio transcript: {responseAudio.Transcript}"); + string outputFilePath = $"{responseAudio.Id}.mp3"; + using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) { - Console.WriteLine($"Response audio transcript: {contentPart.AudioTranscript}"); - - string outputFilePath = $"{contentPart.AudioCorrelationId}.mp3"; - using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) - { - outputFileStream.Write(contentPart.AudioBytes); - } - Console.WriteLine($"Response audio written to file: {outputFilePath}"); - Console.WriteLine($"Valid on followup requests until: {contentPart.AudioExpiresAt}"); + outputFileStream.Write(responseAudio.Data); } + Console.WriteLine($"Response audio written to file: {outputFilePath}"); + Console.WriteLine($"Valid on followup requests until: {responseAudio.ExpiresAt}"); } } PrintAudioContent(); -// To refer to past audio output, create an assistant message from the earlier ChatCompletion, use the earlier -// response content part, or use ChatMessageContentPart.CreateAudioPart(string) to manually instantiate a part. - +// To refer to past audio output, create an assistant message from the earlier ChatCompletion or instantiate a +// ChatResponseAudioReference(string) from the .Id of the completion's .ResponseAudio property. messages.Add(new AssistantChatMessage(completion)); messages.Add("Can you say that like a pirate?"); diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index c57f4943a..8ed7eb820 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1131,6 +1131,7 @@ public class AssistantChatMessage : ChatMessage, IJsonModel parameter instead.")] public AssistantChatMessage(ChatFunctionCall functionCall); public AssistantChatMessage(params ChatMessageContentPart[] contentParts); + public AssistantChatMessage(ChatResponseAudioReference responseAudioReference); public AssistantChatMessage(IEnumerable contentParts); public AssistantChatMessage(IEnumerable toolCalls); public AssistantChatMessage(string content); @@ -1138,6 +1139,7 @@ public class AssistantChatMessage : ChatMessage, IJsonModel ToolCalls { get; } protected override ChatMessage JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options); protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options); @@ -1184,6 +1186,7 @@ public class ChatCompletion : IJsonModel, IPersistableModel RefusalTokenLogProbabilities { get; } + public ChatResponseAudio ResponseAudio { get; } public ChatMessageRole Role { get; } public string SystemFingerprint { get; } public IReadOnlyList ToolCalls { get; } @@ -1289,6 +1292,7 @@ public class ChatMessage : IJsonModel, IPersistableModel contentParts); public static AssistantChatMessage CreateAssistantMessage(IEnumerable toolCalls); public static AssistantChatMessage CreateAssistantMessage(string content); @@ -1315,10 +1319,7 @@ public class ChatMessageContent : ObjectModel.Collection } public class ChatMessageContentPart : IJsonModel, IPersistableModel { public BinaryData AudioBytes { get; } - public string AudioCorrelationId { get; } - public DateTimeOffset? AudioExpiresAt { get; } public ChatInputAudioFormat? AudioInputFormat { get; } - public string AudioTranscript { get; } public BinaryData ImageBytes { get; } public string ImageBytesMediaType { get; } public ChatImageDetailLevel? ImageDetailLevel { get; } @@ -1326,10 +1327,9 @@ public class ChatMessageContentPart : IJsonModel, IPersi public ChatMessageContentPartKind Kind { get; } public string Refusal { get; } public string Text { get; } - public static ChatMessageContentPart CreateAudioPart(BinaryData audioBytes, ChatInputAudioFormat audioFormat); - public static ChatMessageContentPart CreateAudioPart(string audioCorrelationId); public static ChatMessageContentPart CreateImagePart(BinaryData imageBytes, string imageBytesMediaType, ChatImageDetailLevel? imageDetailLevel = null); public static ChatMessageContentPart CreateImagePart(Uri imageUri, ChatImageDetailLevel? imageDetailLevel = null); + public static ChatMessageContentPart CreateInputAudioPart(BinaryData audioBytes, ChatInputAudioFormat audioFormat); public static ChatMessageContentPart CreateRefusalPart(string refusal); public static ChatMessageContentPart CreateTextPart(string text); public static explicit operator ChatMessageContentPart(ClientResult result); @@ -1372,6 +1372,20 @@ public class ChatOutputTokenUsageDetails : IJsonModel, IPersistableModel { + public BinaryData Data { get; } + public DateTimeOffset ExpiresAt { get; } + public string Id { get; } + public string Transcript { get; } + public static explicit operator ChatResponseAudio(ClientResult result); + public static implicit operator BinaryContent(ChatResponseAudio chatResponseAudio); + } + public class ChatResponseAudioReference : IJsonModel, IPersistableModel { + public ChatResponseAudioReference(string id); + public string Id { get; } + public static explicit operator ChatResponseAudioReference(ClientResult result); + public static implicit operator BinaryContent(ChatResponseAudioReference chatResponseAudioReference); + } public class ChatResponseFormat : IJsonModel, IPersistableModel { public static ChatResponseFormat CreateJsonObjectFormat(); public static ChatResponseFormat CreateJsonSchemaFormat(string jsonSchemaFormatName, BinaryData jsonSchema, string jsonSchemaFormatDescription = null, bool? jsonSchemaIsStrict = null); @@ -1466,13 +1480,14 @@ public class FunctionChatMessage : ChatMessage, IJsonModel, protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options); } public static class OpenAIChatModelFactory { - public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, BinaryData audioBytes = null, string audioCorrelationId = null, string audioTranscript = null, DateTimeOffset? audioExpiresAt = null); + public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatResponseAudio responseAudio = null); public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = 0, int cachedTokenCount = 0); public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = 0, int audioTokenCount = 0); + public static ChatResponseAudio ChatResponseAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default); public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null); public static ChatTokenTopLogProbabilityDetails ChatTokenTopLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null); public static ChatTokenUsage ChatTokenUsage(int outputTokenCount = 0, int inputTokenCount = 0, int totalTokenCount = 0, ChatOutputTokenUsageDetails outputTokenDetails = null, ChatInputTokenUsageDetails inputTokenDetails = null); - public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string completionId = null, ChatMessageContent contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, string audioCorrelationId = null, string audioTranscript = null, BinaryData audioBytes = null, DateTimeOffset? audioExpiresAt = null); + public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string completionId = null, ChatMessageContent contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatResponseAudio responseAudio = null); [Obsolete("This class is obsolete. Please use StreamingChatToolCallUpdate instead.")] public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionName = null, BinaryData functionArgumentsUpdate = null); public static StreamingChatToolCallUpdate StreamingChatToolCallUpdate(int index = 0, string toolCallId = null, ChatToolCallKind kind = ChatToolCallKind.Function, string functionName = null, BinaryData functionArgumentsUpdate = null); @@ -1488,6 +1503,7 @@ public class StreamingChatCompletionUpdate : IJsonModel RefusalTokenLogProbabilities { get; } public string RefusalUpdate { get; } + public ChatResponseAudio ResponseAudio { get; } public ChatMessageRole? Role { get; } public string SystemFingerprint { get; } public IReadOnlyList ToolCallUpdates { get; } diff --git a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs index 758e538e2..848a47830 100644 --- a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs +++ b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs @@ -20,7 +20,7 @@ public void Example09_ChatWithAudio() BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); List messages = [ - new UserChatMessage(ChatMessageContentPart.CreateAudioPart(audioData, ChatInputAudioFormat.Wav)), + new UserChatMessage(ChatMessageContentPart.CreateInputAudioPart(audioData, ChatInputAudioFormat.Wav)), ]; // Output audio is requested by configuring AudioOptions on ChatCompletionOptions @@ -33,20 +33,16 @@ public void Example09_ChatWithAudio() void PrintAudioContent() { - foreach (ChatMessageContentPart contentPart in completion.Content) + if (completion.ResponseAudio is ChatResponseAudio responseAudio) { - if (contentPart.AudioCorrelationId is not null) + Console.WriteLine($"Response audio transcript: {responseAudio.Transcript}"); + string outputFilePath = $"{responseAudio.Id}.mp3"; + using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) { - Console.WriteLine($"Response audio transcript: {contentPart.AudioTranscript}"); - - string outputFilePath = $"{contentPart.AudioCorrelationId}.mp3"; - using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) - { - outputFileStream.Write(contentPart.AudioBytes); - } - Console.WriteLine($"Response audio written to file: {outputFilePath}"); - Console.WriteLine($"Valid on followup requests until: {contentPart.AudioExpiresAt}"); + outputFileStream.Write(responseAudio.Data); } + Console.WriteLine($"Response audio written to file: {outputFilePath}"); + Console.WriteLine($"Valid on followup requests until: {responseAudio.ExpiresAt}"); } } diff --git a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs index 1a8f70748..f1df7a318 100644 --- a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs +++ b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs @@ -21,7 +21,7 @@ public async Task Example09_ChatWithAudioAsync() BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); List messages = [ - new UserChatMessage(ChatMessageContentPart.CreateAudioPart(audioData, ChatInputAudioFormat.Wav)), + new UserChatMessage(ChatMessageContentPart.CreateInputAudioPart(audioData, ChatInputAudioFormat.Wav)), ]; // Output audio is requested by configuring AudioOptions on ChatCompletionOptions @@ -34,20 +34,16 @@ public async Task Example09_ChatWithAudioAsync() async Task PrintAudioContentAsync() { - foreach (ChatMessageContentPart contentPart in completion.Content) + if (completion.ResponseAudio is ChatResponseAudio responseAudio) { - if (contentPart.AudioCorrelationId is not null) + Console.WriteLine($"Response audio transcript: {responseAudio.Transcript}"); + string outputFilePath = $"{responseAudio.Id}.mp3"; + using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) { - Console.WriteLine($"Response audio transcript: {contentPart.AudioTranscript}"); - - string outputFilePath = $"{contentPart.AudioCorrelationId}.mp3"; - using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) - { - await outputFileStream.WriteAsync(contentPart.AudioBytes); - } - Console.WriteLine($"Response audio written to file: {outputFilePath}"); - Console.WriteLine($"Valid on followup requests until: {contentPart.AudioExpiresAt}"); + await outputFileStream.WriteAsync(responseAudio.Data); } + Console.WriteLine($"Response audio written to file: {outputFilePath}"); + Console.WriteLine($"Valid on followup requests until: {responseAudio.ExpiresAt}"); } } diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs index 13e493295..41fa66f7c 100644 --- a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs @@ -1,7 +1,4 @@ -using System; using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Linq; using System.Text.Json; namespace OpenAI.Chat; @@ -22,22 +19,9 @@ internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions writer.WriteStringValue(Role.ToSerialString()); // Content is optional, can be a single string or a collection of ChatMessageContentPart. - if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined() && Content.Count > 0) + if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) { - // AssistantChatMessage contrives a ChatMessageContent instance to expose the otherwise unrelated audio - // information as multimodal content. For serialization, we need to ensure the underlying, non-projected - // representation is populated. - if (Audio is null) - { - ChatMessageContentPart audioReferenceContentPart - = Content.FirstOrDefault(contentPart => !string.IsNullOrEmpty(contentPart.AudioCorrelationId)); - if (audioReferenceContentPart is not null) - { - Audio = new(audioReferenceContentPart.AudioCorrelationId); - } - } - - if (Content.Any(contentPart => !contentPart.IsContrived)) + if (Content.Count > 0) { writer.WritePropertyName("content"u8); if (Content.Count == 1 && Content[0].Text != null) @@ -49,10 +33,7 @@ ChatMessageContentPart audioReferenceContentPart writer.WriteStartArray(); foreach (ChatMessageContentPart part in Content) { - if (!part.IsContrived) - { - writer.WriteObjectValue(part, options); - } + writer.WriteObjectValue(part, options); } writer.WriteEndArray(); } @@ -63,105 +44,8 @@ ChatMessageContentPart audioReferenceContentPart writer.WriteOptionalProperty("name"u8, ParticipantName, options); writer.WriteOptionalCollection("tool_calls"u8, ToolCalls, options); writer.WriteOptionalProperty("function_call"u8, FunctionCall, options); - writer.WriteOptionalProperty("audio"u8, Audio, options); + writer.WriteOptionalProperty("audio"u8, ResponseAudioReference, options); writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); writer.WriteEndObject(); } - - internal static AssistantChatMessage DeserializeAssistantChatMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - string refusal = default; - string name = default; - InternalChatCompletionRequestAssistantMessageAudio audio = default; - IList toolCalls = default; - ChatFunctionCall functionCall = default; - ChatMessageRole role = default; - ChatMessageContent content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("refusal"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - refusal = null; - continue; - } - refusal = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("audio"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - audio = null; - continue; - } - audio = InternalChatCompletionRequestAssistantMessageAudio.DeserializeInternalChatCompletionRequestAssistantMessageAudio(property.Value, options); - 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().ToChatMessageRole(); - continue; - } - if (property.NameEquals("content"u8)) - { - DeserializeContentValue(property, ref content); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - // CUSTOM: Initialize Content collection property. - // If applicable, prepend a contrived content part representing an ID-based audio reference. - content ??= new(); - if (audio is not null) - { - content.Insert(0, new ChatMessageContentPart(ChatMessageContentPartKind.Audio, audioReference: new(audio.Id))); - } - return new AssistantChatMessage( - content ?? new ChatMessageContent(), - role, - serializedAdditionalRawData, - refusal, - name, - toolCalls ?? new ChangeTrackingList(), - functionCall, - audio); - } } diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.cs b/.dotnet/src/Custom/Chat/AssistantChatMessage.cs index d1a03084c..261aaec9b 100644 --- a/.dotnet/src/Custom/Chat/AssistantChatMessage.cs +++ b/.dotnet/src/Custom/Chat/AssistantChatMessage.cs @@ -84,6 +84,18 @@ public AssistantChatMessage(ChatFunctionCall functionCall) FunctionCall = functionCall; } + /// + /// Creates a new instance of that represents a prior response from the model + /// that included audio with a correlation ID. + /// + /// The audio reference with an id, produced by the model. + public AssistantChatMessage(ChatResponseAudioReference responseAudioReference) + { + Argument.AssertNotNull(responseAudioReference, nameof(responseAudioReference)); + + ResponseAudioReference = responseAudioReference; + } + /// /// Creates a new instance of from a with /// an assistant role response. @@ -110,6 +122,10 @@ public AssistantChatMessage(ChatCompletion chatCompletion) Refusal = chatCompletion.Refusal; FunctionCall = chatCompletion.FunctionCall; + if (chatCompletion.ResponseAudio is not null) + { + ResponseAudioReference = new(chatCompletion.ResponseAudio.Id); + } foreach (ChatToolCall toolCall in chatCompletion.ToolCalls ?? []) { ToolCalls.Add(toolCall); @@ -134,5 +150,5 @@ public AssistantChatMessage(ChatCompletion chatCompletion) // CUSTOM: Made internal for reprojected representation within the content collection. [CodeGenMember("Audio")] - internal InternalChatCompletionRequestAssistantMessageAudio Audio { get; set; } + public ChatResponseAudioReference ResponseAudioReference { get; set; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatCompletion.cs b/.dotnet/src/Custom/Chat/ChatCompletion.cs index 594aa61fc..ad76ca8b6 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletion.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletion.cs @@ -71,8 +71,7 @@ public partial class ChatCompletion // CUSTOM: Flattened choice message property. /// The contents of the message. - public ChatMessageContent Content => _content ??= GetWrappedContent(); - private ChatMessageContent _content; + public ChatMessageContent Content => Choices[0].Message.Content; // CUSTOM: Flattened choice message property. /// The tool calls generated by the model, such as function calls. @@ -86,19 +85,6 @@ public partial class ChatCompletion [Obsolete($"This property is obsolete. Please use {nameof(ToolCalls)} instead.")] public ChatFunctionCall FunctionCall => Choices[0].Message.FunctionCall; - private ChatMessageContent GetWrappedContent() - { - if (Choices[0].Message.Audio is not null) - { - return new ChatMessageContent( - [ - new ChatMessageContentPart(ChatMessageContentPartKind.Audio, outputAudio: Choices[0].Message.Audio), - ..Choices[0].Message.Content, - ]); - } - else - { - return Choices[0].Message.Content; - } - } + /// The audio response generated by the model. + public ChatResponseAudio ResponseAudio => Choices[0].Message.Audio; } diff --git a/.dotnet/src/Custom/Chat/ChatMessage.cs b/.dotnet/src/Custom/Chat/ChatMessage.cs index 1adfbb38b..4e2d91320 100644 --- a/.dotnet/src/Custom/Chat/ChatMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatMessage.cs @@ -81,14 +81,7 @@ internal ChatMessage(ChatMessageRole role, IEnumerable c { foreach (ChatMessageContentPart contentPart in contentParts) { - if (contentPart.Kind == ChatMessageContentPartKind.Audio && role == ChatMessageRole.Assistant) - { - Content.Add(new ChatMessageContentPart(ChatMessageContentPartKind.Audio, audioReference: new(contentPart.AudioCorrelationId))); - } - else - { - Content.Add(contentPart); - } + Content.Add(contentPart); } } } @@ -141,6 +134,10 @@ internal ChatMessage(ChatMessageRole role, string content = null) : this(role) /// public static AssistantChatMessage CreateAssistantMessage(ChatCompletion chatCompletion) => new(chatCompletion); + + /// + public static AssistantChatMessage CreateAssistantMessage(ChatResponseAudioReference audioReference) => new(audioReference); + #endregion #region ToolChatMessage diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs index 8afaf8151..2b8d1b2e6 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs @@ -14,13 +14,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader internal static void WriteCoreContentPart(ChatMessageContentPart instance, Utf8JsonWriter writer, ModelReaderWriterOptions options) { - if (instance.IsContrived) - { - throw new InvalidOperationException( - $"Synthetic {nameof(ChatMessageContentPart)} instances cannot be directly serialized. " - + $"Instead, please serialize the owner of the {nameof(ChatMessageContent)} collection."); - } - writer.WriteStartObject(); writer.WritePropertyName("type"u8); writer.WriteStringValue(instance._kind.ToSerialString()); @@ -99,6 +92,6 @@ internal static ChatMessageContentPart DeserializeChatMessageContentPart(JsonEle } } serializedAdditionalRawData = rawDataDictionary; - return new ChatMessageContentPart(kind, text, imageUri, refusal, inputAudio, outputAudio: null, responseAudioUpdate: null, audioReference: null, serializedAdditionalRawData); + return new ChatMessageContentPart(kind, text, imageUri, refusal, inputAudio, serializedAdditionalRawData); } } diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs index 65bce4bd7..295ae8ac9 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs @@ -19,6 +19,10 @@ namespace OpenAI.Chat; /// Call to create a that /// encapsulates a refusal coming from the model. /// +/// +/// Call to create a content part +/// encapsulating input audio for user role messages. +/// /// /// [CodeGenModel("ChatMessageContentPart")] @@ -29,9 +33,6 @@ public partial class ChatMessageContentPart private readonly string _text; private readonly InternalChatCompletionRequestMessageContentPartImageImageUrl _imageUri; private readonly InternalChatCompletionRequestMessageContentPartAudioInputAudio _inputAudio; - private readonly InternalChatCompletionResponseMessageAudio _outputAudio; - private readonly InternalChatCompletionMessageAudioChunk _responseAudioUpdate; - private readonly InternalChatCompletionRequestAssistantMessageAudio _audioReference; private readonly string _refusal; // CUSTOM: Made internal. @@ -46,9 +47,6 @@ internal ChatMessageContentPart( InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default, string refusal = default, InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default, - InternalChatCompletionResponseMessageAudio outputAudio = default, - InternalChatCompletionMessageAudioChunk responseAudioUpdate = default, - InternalChatCompletionRequestAssistantMessageAudio audioReference = default, IDictionary serializedAdditionalRawData = default) { _kind = kind; @@ -56,9 +54,6 @@ internal ChatMessageContentPart( _imageUri = imageUri; _refusal = refusal; _inputAudio = inputAudio; - _outputAudio = outputAudio; - _responseAudioUpdate = responseAudioUpdate; - _audioReference = audioReference; _additionalBinaryDataProperties = serializedAdditionalRawData; } @@ -90,12 +85,9 @@ internal ChatMessageContentPart( /// /// /// Present when is and the content part - /// represents user role audio input or response audio content from the model. - /// - /// When streaming, this value represents the latest incremental audio update. - /// + /// represents user role audio input. /// - public BinaryData AudioBytes => _inputAudio?.Data ?? _outputAudio?.Data ?? _responseAudioUpdate?.Data; + public BinaryData AudioBytes => _inputAudio?.Data; /// /// The encoding format that the audio data provided in should be interpreted with. @@ -106,37 +98,6 @@ internal ChatMessageContentPart( /// public ChatInputAudioFormat? AudioInputFormat => _inputAudio?.Format; - /// - /// The unique identifier, as provided with model-generated response audio, that may be supplied as assistant - /// conversation history. - /// - /// - /// Present when is and the content part - /// represents response audio from the service or assistant role historical audio input. - /// - public string AudioCorrelationId => _audioReference?.Id ?? _outputAudio?.Id ?? _responseAudioUpdate?.Id; - - /// - /// The timestamp after which the audio associated with is no longer available. - /// - /// - /// Present when is and the content part - /// represents response audio from the service. - /// - public DateTimeOffset? AudioExpiresAt => _outputAudio?.ExpiresAt ?? _responseAudioUpdate?.ExpiresAt; - - /// - /// The transcript that approximates the content of the audio provided by . - /// - /// - /// Present when is and the content part - /// represents response audio from the service. - /// - /// When streaming, this value represents the latest transcript update. - /// - /// - public string AudioTranscript => _outputAudio?.Transcript ?? _responseAudioUpdate?.Transcript; - // CUSTOM: Spread. /// /// The level of detail with which the model should process the image and generate its textual understanding of @@ -210,11 +171,11 @@ public static ChatMessageContentPart CreateRefusalPart(string refusal) /// Creates a new that encapsulates user role input audio in a known format. /// /// Binary audio content parts may only be used with instances to represent user audio input. When referring to - /// past audio output from the model, use instead. + /// past audio output from the model, use instead. /// /// The audio data. /// The format of the audio data. - public static ChatMessageContentPart CreateAudioPart(BinaryData audioBytes, ChatInputAudioFormat audioFormat) + public static ChatMessageContentPart CreateInputAudioPart(BinaryData audioBytes, ChatInputAudioFormat audioFormat) { Argument.AssertNotNull(audioBytes, nameof(audioBytes)); @@ -223,22 +184,6 @@ public static ChatMessageContentPart CreateAudioPart(BinaryData audioBytes, Chat inputAudio: new(audioBytes, audioFormat)); } - /// Creates a new that encapsulates an ID-based reference to earlier response audio provided by the model. - /// - /// Reference-based audio content parts are used with instances to represent historical audio output from the model. When providing - /// user audio input, use instead. - /// - /// The unique identifier associated with the audio. - /// is null. - public static ChatMessageContentPart CreateAudioPart(string audioCorrelationId) - { - Argument.AssertNotNull(audioCorrelationId, nameof(audioCorrelationId)); - - return new( - kind: ChatMessageContentPartKind.Audio, - audioReference: new InternalChatCompletionRequestAssistantMessageAudio(audioCorrelationId, null)); - } - /// /// Implicitly intantiates a new from a . As such, /// using a in place of a is equivalent to calling the @@ -246,22 +191,4 @@ public static ChatMessageContentPart CreateAudioPart(string audioCorrelationId) /// /// The text encapsulated by this . public static implicit operator ChatMessageContentPart(string text) => CreateTextPart(text); - - /// - /// Gets a value indicating whether this content part is contrived, in which case it does not represent a valid - /// member of a JSON content array within a REST body. - /// - internal bool IsContrived - { - get - { - // Audio content parts representing ID-based references or response audio are synthesized from dedicated - // "audio" JSON properties. - if (_kind == ChatMessageContentPartKind.Audio && _inputAudio is null) - { - return true; - } - return false; - } - } } diff --git a/.dotnet/src/Custom/Chat/ChatResponseAudio.cs b/.dotnet/src/Custom/Chat/ChatResponseAudio.cs new file mode 100644 index 000000000..54f1fe210 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatResponseAudio.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace OpenAI.Chat; + +[CodeGenModel("ChatCompletionResponseMessageAudio")] +public partial class ChatResponseAudio +{ + +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatResponseAudioReference.cs b/.dotnet/src/Custom/Chat/ChatResponseAudioReference.cs new file mode 100644 index 000000000..2a6465202 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatResponseAudioReference.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace OpenAI.Chat; + +[CodeGenModel("ChatCompletionRequestAssistantMessageAudio")] +public partial class ChatResponseAudioReference +{ +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs index 2f64daf92..6a2a78016 100644 --- a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs @@ -102,12 +102,6 @@ internal readonly partial struct InternalCreateChatCompletionRequestModality { } [CodeGenModel("ChatCompletionRequestMessageContentPartAudioType")] internal readonly partial struct InternalChatCompletionRequestMessageContentPartAudioType { } -[CodeGenModel("ChatCompletionRequestAssistantMessageAudio")] -internal partial class InternalChatCompletionRequestAssistantMessageAudio { } - -[CodeGenModel("ChatCompletionResponseMessageAudio")] -internal partial class InternalChatCompletionResponseMessageAudio { } - [CodeGenModel("ChatCompletionMessageAudioChunk")] internal partial class InternalChatCompletionMessageAudioChunk { } diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs index 80c111996..171de51a5 100644 --- a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs @@ -16,4 +16,9 @@ internal partial class InternalChatCompletionStreamResponseDelta /// The contents of the message. [CodeGenMember("Content")] public ChatMessageContent Content { get; } + + // CUSTOM: Changed type to share with non-streaming response audio. + /// The incremental response audio information for the message. + [CodeGenMember("Audio")] + public ChatResponseAudio Audio { get; } } diff --git a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs index aeabf2630..3b87a1416 100644 --- a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs +++ b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -23,26 +23,17 @@ public static ChatCompletion ChatCompletion( string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, - BinaryData audioBytes = null, - string audioCorrelationId = null, - string audioTranscript = null, - DateTimeOffset? audioExpiresAt = null) + ChatResponseAudio responseAudio = null) { content ??= new ChatMessageContent(); toolCalls ??= new List(); contentTokenLogProbabilities ??= new List(); refusalTokenLogProbabilities ??= new List(); - InternalChatCompletionResponseMessageAudio audio = null; - if (audioCorrelationId is not null || audioExpiresAt is not null || audioBytes is not null || audioTranscript is not null) - { - audio = new(audioCorrelationId, audioExpiresAt ?? default, audioBytes, audioTranscript); - } - InternalChatCompletionResponseMessage message = new InternalChatCompletionResponseMessage( refusal, toolCalls.ToList(), - audio, + responseAudio, role, content, functionCall, @@ -74,6 +65,7 @@ public static ChatCompletion ChatCompletion( additionalBinaryDataProperties: null); } + /// Initializes a new instance of . /// A new instance for mocking. public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = default, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null) @@ -129,6 +121,16 @@ public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reason return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, additionalBinaryDataProperties: null); } + public static ChatResponseAudio ChatResponseAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default) + { + return new ChatResponseAudio( + id, + expiresAt, + data, + transcript, + additionalBinaryDataProperties: null); + } + /// Initializes a new instance of . /// A new instance for mocking. public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate( @@ -145,29 +147,20 @@ public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate( string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, - string audioCorrelationId = null, - string audioTranscript = null, - BinaryData audioBytes = null, - DateTimeOffset? audioExpiresAt = null) + ChatResponseAudio responseAudio = null) { contentUpdate ??= new ChatMessageContent(); toolCallUpdates ??= new List(); contentTokenLogProbabilities ??= new List(); refusalTokenLogProbabilities ??= new List(); - InternalChatCompletionMessageAudioChunk audio = null; - if (audioCorrelationId is not null || audioTranscript is not null || audioBytes is not null || audioExpiresAt is not null) - { - audio = new(audioCorrelationId, audioTranscript, audioBytes, audioExpiresAt, additionalBinaryDataProperties: null); - } - InternalChatCompletionStreamResponseDelta delta = new InternalChatCompletionStreamResponseDelta( - audio, functionCallUpdate, toolCallUpdates.ToList(), refusalUpdate, role, contentUpdate, + responseAudio, additionalBinaryDataProperties: null); InternalCreateChatCompletionStreamResponseChoiceLogprobs logprobs = new InternalCreateChatCompletionStreamResponseChoiceLogprobs( diff --git a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs index 01a5ec011..1707f1aaf 100644 --- a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs +++ b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs @@ -93,7 +93,7 @@ public partial class StreamingChatCompletionUpdate /// Each streaming update contains only a small portion of tokens. To reconstitute the entire chat completion, /// all values across streaming updates must be combined. /// - public ChatMessageContent ContentUpdate => _contentUpdate ??= GetWrappedContentUpdate(); + public ChatMessageContent ContentUpdate => _contentUpdate ??= InternalChoiceDelta?.Content ?? []; // CUSTOM: Flattened choice delta property. /// The tool calls generated by the model, such as function calls. @@ -110,21 +110,5 @@ public IReadOnlyList ToolCallUpdates [Obsolete($"This property is obsolete. Please use {nameof(ToolCallUpdates)} instead.")] public StreamingChatFunctionCallUpdate FunctionCallUpdate => InternalChoiceDelta?.FunctionCall; - private ChatMessageContent GetWrappedContentUpdate() - { - ChatMessageContent wrappedResult = new(); - - if (InternalChoiceDelta?.Audio is not null) - { - wrappedResult.Add(new ChatMessageContentPart( - ChatMessageContentPartKind.Audio, - responseAudioUpdate: InternalChoiceDelta.Audio)); - } - foreach (ChatMessageContentPart deltaContentPart in InternalChoiceDelta?.Content ?? []) - { - wrappedResult.Add(deltaContentPart); - } - - return wrappedResult; - } + public ChatResponseAudio ResponseAudio => InternalChoiceDelta?.Audio; } diff --git a/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs index b4782f168..45fab83f5 100644 --- a/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs @@ -5,6 +5,7 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using OpenAI; @@ -59,12 +60,12 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteNull("functionCall"u8); } } - if (Optional.IsDefined(Audio) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) + if (Optional.IsDefined(ResponseAudioReference) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) { - if (Audio != null) + if (ResponseAudioReference != null) { writer.WritePropertyName("audio"u8); - writer.WriteObjectValue(Audio, options); + writer.WriteObjectValue(ResponseAudioReference, options); } else { @@ -83,7 +84,99 @@ protected override ChatMessage JsonModelCreateCore(ref Utf8JsonReader reader, Mo throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return AssistantChatMessage.DeserializeAssistantChatMessage(document.RootElement, options); + return DeserializeAssistantChatMessage(document.RootElement, options); + } + + internal static AssistantChatMessage DeserializeAssistantChatMessage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ChatMessageContent content = default; + Chat.ChatMessageRole role = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string refusal = default; + string participantName = default; + IList toolCalls = default; + ChatFunctionCall functionCall = default; + ChatResponseAudioReference responseAudioReference = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("content"u8)) + { + DeserializeContentValue(prop, ref content); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = prop.Value.GetString().ToChatMessageRole(); + continue; + } + if (prop.NameEquals("refusal"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + refusal = null; + continue; + } + refusal = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + participantName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tool_calls"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ChatToolCall.DeserializeChatToolCall(item, options)); + } + toolCalls = array; + continue; + } + if (prop.NameEquals("function_call"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + functionCall = null; + continue; + } + functionCall = ChatFunctionCall.DeserializeChatFunctionCall(prop.Value, options); + continue; + } + if (prop.NameEquals("audio"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + responseAudioReference = null; + continue; + } + responseAudioReference = ChatResponseAudioReference.DeserializeChatResponseAudioReference(prop.Value, options); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + // CUSTOM: Initialize Content collection property. + return new AssistantChatMessage( + content ?? new ChatMessageContent(), + role, + additionalBinaryDataProperties, + refusal, + participantName, + toolCalls ?? new ChangeTrackingList(), + functionCall, + responseAudioReference); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); @@ -110,7 +203,7 @@ protected override ChatMessage PersistableModelCreateCore(BinaryData data, Model case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return AssistantChatMessage.DeserializeAssistantChatMessage(document.RootElement, options); + return DeserializeAssistantChatMessage(document.RootElement, options); } default: throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support reading '{options.Format}' format."); @@ -132,7 +225,7 @@ public static explicit operator AssistantChatMessage(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return AssistantChatMessage.DeserializeAssistantChatMessage(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeAssistantChatMessage(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/AssistantChatMessage.cs b/.dotnet/src/Generated/Models/AssistantChatMessage.cs index d84662667..6975e7bd3 100644 --- a/.dotnet/src/Generated/Models/AssistantChatMessage.cs +++ b/.dotnet/src/Generated/Models/AssistantChatMessage.cs @@ -9,13 +9,13 @@ namespace OpenAI.Chat { public partial class AssistantChatMessage : ChatMessage { - internal AssistantChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, InternalChatCompletionRequestAssistantMessageAudio audio) : base(content, role, additionalBinaryDataProperties) + internal AssistantChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, ChatResponseAudioReference responseAudioReference) : base(content, role, additionalBinaryDataProperties) { Refusal = refusal; ParticipantName = participantName; ToolCalls = toolCalls; FunctionCall = functionCall; - Audio = audio; + ResponseAudioReference = responseAudioReference; } public string Refusal { get; set; } diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.Serialization.cs b/.dotnet/src/Generated/Models/ChatResponseAudio.Serialization.cs similarity index 59% rename from .dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.Serialization.cs rename to .dotnet/src/Generated/Models/ChatResponseAudio.Serialization.cs index 83bbc49e6..40e982773 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatResponseAudio.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Chat { - internal partial class InternalChatCompletionResponseMessageAudio : IJsonModel + public partial class ChatResponseAudio : IJsonModel { - internal InternalChatCompletionResponseMessageAudio() + internal ChatResponseAudio() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Write(Utf8JsonWriter protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageAudio)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(ChatResponseAudio)} does not support writing '{format}' format."); } if (_additionalBinaryDataProperties?.ContainsKey("id") != true) { @@ -72,20 +72,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalChatCompletionResponseMessageAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + ChatResponseAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual InternalChatCompletionResponseMessageAudio JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual ChatResponseAudio JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageAudio)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(ChatResponseAudio)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionResponseMessageAudio(document.RootElement, options); + return DeserializeChatResponseAudio(document.RootElement, options); } - internal static InternalChatCompletionResponseMessageAudio DeserializeInternalChatCompletionResponseMessageAudio(JsonElement element, ModelReaderWriterOptions options) + internal static ChatResponseAudio DeserializeChatResponseAudio(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -123,56 +123,56 @@ internal static InternalChatCompletionResponseMessageAudio DeserializeInternalCh additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalChatCompletionResponseMessageAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties); + return new ChatResponseAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageAudio)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(ChatResponseAudio)} does not support writing '{options.Format}' format."); } } - InternalChatCompletionResponseMessageAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + ChatResponseAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual InternalChatCompletionResponseMessageAudio PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual ChatResponseAudio PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalChatCompletionResponseMessageAudio(document.RootElement, options); + return DeserializeChatResponseAudio(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageAudio)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(ChatResponseAudio)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalChatCompletionResponseMessageAudio internalChatCompletionResponseMessageAudio) + public static implicit operator BinaryContent(ChatResponseAudio chatResponseAudio) { - if (internalChatCompletionResponseMessageAudio == null) + if (chatResponseAudio == null) { return null; } - return BinaryContent.Create(internalChatCompletionResponseMessageAudio, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(chatResponseAudio, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalChatCompletionResponseMessageAudio(ClientResult result) + public static explicit operator ChatResponseAudio(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionResponseMessageAudio(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeChatResponseAudio(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.cs b/.dotnet/src/Generated/Models/ChatResponseAudio.cs similarity index 70% rename from .dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.cs rename to .dotnet/src/Generated/Models/ChatResponseAudio.cs index 28ce7fb60..395622cac 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessageAudio.cs +++ b/.dotnet/src/Generated/Models/ChatResponseAudio.cs @@ -7,11 +7,11 @@ namespace OpenAI.Chat { - internal partial class InternalChatCompletionResponseMessageAudio + public partial class ChatResponseAudio { private protected IDictionary _additionalBinaryDataProperties; - internal InternalChatCompletionResponseMessageAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript) + internal ChatResponseAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript) { Id = id; ExpiresAt = expiresAt; @@ -19,7 +19,7 @@ internal InternalChatCompletionResponseMessageAudio(string id, DateTimeOffset ex Transcript = transcript; } - internal InternalChatCompletionResponseMessageAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript, IDictionary additionalBinaryDataProperties) + internal ChatResponseAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript, IDictionary additionalBinaryDataProperties) { Id = id; ExpiresAt = expiresAt; diff --git a/.dotnet/src/Generated/Models/ChatResponseAudioReference.Serialization.cs b/.dotnet/src/Generated/Models/ChatResponseAudioReference.Serialization.cs new file mode 100644 index 000000000..57bf8862f --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatResponseAudioReference.Serialization.cs @@ -0,0 +1,145 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + public partial class ChatResponseAudioReference : IJsonModel + { + internal ChatResponseAudioReference() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatResponseAudioReference)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChatResponseAudioReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual ChatResponseAudioReference JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatResponseAudioReference)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatResponseAudioReference(document.RootElement, options); + } + + internal static ChatResponseAudioReference DeserializeChatResponseAudioReference(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChatResponseAudioReference(id, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatResponseAudioReference)} does not support writing '{options.Format}' format."); + } + } + + ChatResponseAudioReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual ChatResponseAudioReference PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeChatResponseAudioReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatResponseAudioReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(ChatResponseAudioReference chatResponseAudioReference) + { + if (chatResponseAudioReference == null) + { + return null; + } + return BinaryContent.Create(chatResponseAudioReference, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator ChatResponseAudioReference(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeChatResponseAudioReference(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.cs b/.dotnet/src/Generated/Models/ChatResponseAudioReference.cs similarity index 69% rename from .dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.cs rename to .dotnet/src/Generated/Models/ChatResponseAudioReference.cs index 9976eda78..6ae6cc6fa 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.cs +++ b/.dotnet/src/Generated/Models/ChatResponseAudioReference.cs @@ -8,18 +8,18 @@ namespace OpenAI.Chat { - internal partial class InternalChatCompletionRequestAssistantMessageAudio + public partial class ChatResponseAudioReference { private protected IDictionary _additionalBinaryDataProperties; - public InternalChatCompletionRequestAssistantMessageAudio(string id) + public ChatResponseAudioReference(string id) { Argument.AssertNotNull(id, nameof(id)); Id = id; } - internal InternalChatCompletionRequestAssistantMessageAudio(string id, IDictionary additionalBinaryDataProperties) + internal ChatResponseAudioReference(string id, IDictionary additionalBinaryDataProperties) { Id = id; _additionalBinaryDataProperties = additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.Serialization.cs deleted file mode 100644 index ffc87fbb0..000000000 --- a/.dotnet/src/Generated/Models/InternalChatCompletionRequestAssistantMessageAudio.Serialization.cs +++ /dev/null @@ -1,145 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Chat -{ - internal partial class InternalChatCompletionRequestAssistantMessageAudio : IJsonModel - { - internal InternalChatCompletionRequestAssistantMessageAudio() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestAssistantMessageAudio)} does not support writing '{format}' format."); - } - if (_additionalBinaryDataProperties?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (true && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - InternalChatCompletionRequestAssistantMessageAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - protected virtual InternalChatCompletionRequestAssistantMessageAudio JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestAssistantMessageAudio)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionRequestAssistantMessageAudio(document.RootElement, options); - } - - internal static InternalChatCompletionRequestAssistantMessageAudio DeserializeInternalChatCompletionRequestAssistantMessageAudio(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("id"u8)) - { - id = prop.Value.GetString(); - continue; - } - if (true) - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new InternalChatCompletionRequestAssistantMessageAudio(id, additionalBinaryDataProperties); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestAssistantMessageAudio)} does not support writing '{options.Format}' format."); - } - } - - InternalChatCompletionRequestAssistantMessageAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - protected virtual InternalChatCompletionRequestAssistantMessageAudio PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalChatCompletionRequestAssistantMessageAudio(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestAssistantMessageAudio)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalChatCompletionRequestAssistantMessageAudio internalChatCompletionRequestAssistantMessageAudio) - { - if (internalChatCompletionRequestAssistantMessageAudio == null) - { - return null; - } - return BinaryContent.Create(internalChatCompletionRequestAssistantMessageAudio, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalChatCompletionRequestAssistantMessageAudio(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionRequestAssistantMessageAudio(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs index 25f435f56..c54451765 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs @@ -129,7 +129,7 @@ internal static InternalChatCompletionResponseMessage DeserializeInternalChatCom } string refusal = default; IReadOnlyList toolCalls = default; - InternalChatCompletionResponseMessageAudio audio = default; + ChatResponseAudio audio = default; Chat.ChatMessageRole role = default; ChatMessageContent content = default; ChatFunctionCall functionCall = default; @@ -167,7 +167,7 @@ internal static InternalChatCompletionResponseMessage DeserializeInternalChatCom audio = null; continue; } - audio = InternalChatCompletionResponseMessageAudio.DeserializeInternalChatCompletionResponseMessageAudio(prop.Value, options); + audio = ChatResponseAudio.DeserializeChatResponseAudio(prop.Value, options); continue; } if (prop.NameEquals("role"u8)) diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs index 0afef0e57..831039448 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs @@ -19,7 +19,7 @@ internal InternalChatCompletionResponseMessage(string refusal, ChatMessageConten Content = content; } - internal InternalChatCompletionResponseMessage(string refusal, IReadOnlyList toolCalls, InternalChatCompletionResponseMessageAudio audio, Chat.ChatMessageRole role, ChatMessageContent content, ChatFunctionCall functionCall, IDictionary additionalBinaryDataProperties) + internal InternalChatCompletionResponseMessage(string refusal, IReadOnlyList toolCalls, ChatResponseAudio audio, Chat.ChatMessageRole role, ChatMessageContent content, ChatFunctionCall functionCall, IDictionary additionalBinaryDataProperties) { Refusal = refusal; ToolCalls = toolCalls; @@ -34,7 +34,7 @@ internal InternalChatCompletionResponseMessage(string refusal, IReadOnlyList ToolCalls { get; } - public InternalChatCompletionResponseMessageAudio Audio { get; } + public ChatResponseAudio Audio { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs index e7d9267ba..217b7e4b1 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs @@ -27,11 +27,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(InternalChatCompletionStreamResponseDelta)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Audio) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) - { - writer.WritePropertyName("audio"u8); - writer.WriteObjectValue(Audio, options); - } if (Optional.IsDefined(FunctionCall) && _additionalBinaryDataProperties?.ContainsKey("function_call") != true) { writer.WritePropertyName("function_call"u8); @@ -77,6 +72,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteNull("content"u8); } } + if (Optional.IsDefined(Audio) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) + { + writer.WritePropertyName("audio"u8); + writer.WriteObjectValue(Audio, options); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -117,24 +117,15 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha { return null; } - InternalChatCompletionMessageAudioChunk audio = default; StreamingChatFunctionCallUpdate functionCall = default; IReadOnlyList toolCalls = default; string refusal = default; Chat.ChatMessageRole? role = default; ChatMessageContent content = default; + ChatResponseAudio audio = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("audio"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - audio = InternalChatCompletionMessageAudioChunk.DeserializeInternalChatCompletionMessageAudioChunk(prop.Value, options); - continue; - } if (prop.NameEquals("function_call"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) @@ -182,6 +173,15 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha DeserializeContentValue(prop, ref content); continue; } + if (prop.NameEquals("audio"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + audio = ChatResponseAudio.DeserializeChatResponseAudio(prop.Value, options); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -189,12 +189,12 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha } // CUSTOM: Initialize Content collection property. return new InternalChatCompletionStreamResponseDelta( - audio, functionCall, toolCalls ?? new ChangeTrackingList(), refusal, role, content ?? new ChatMessageContent(), + audio, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs index 14dd3ca44..ac361d1d1 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs @@ -11,19 +11,17 @@ internal partial class InternalChatCompletionStreamResponseDelta { private protected IDictionary _additionalBinaryDataProperties; - internal InternalChatCompletionStreamResponseDelta(InternalChatCompletionMessageAudioChunk audio, StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, string refusal, Chat.ChatMessageRole? role, ChatMessageContent content, IDictionary additionalBinaryDataProperties) + internal InternalChatCompletionStreamResponseDelta(StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, string refusal, Chat.ChatMessageRole? role, ChatMessageContent content, ChatResponseAudio audio, IDictionary additionalBinaryDataProperties) { - Audio = audio; FunctionCall = functionCall; ToolCalls = toolCalls; Refusal = refusal; Role = role; Content = content; + Audio = audio; _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public InternalChatCompletionMessageAudioChunk Audio { get; } - public StreamingChatFunctionCallUpdate FunctionCall { get; } public IReadOnlyList ToolCalls { get; } diff --git a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs index 8b1a2c459..19cc9073b 100644 --- a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs @@ -57,7 +57,7 @@ internal static InternalFineTuneChatCompletionRequestAssistantMessage Deserializ string participantName = default; IList toolCalls = default; ChatFunctionCall functionCall = default; - InternalChatCompletionRequestAssistantMessageAudio audio = default; + ChatResponseAudioReference responseAudioReference = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("content"u8)) @@ -113,10 +113,10 @@ internal static InternalFineTuneChatCompletionRequestAssistantMessage Deserializ { if (prop.Value.ValueKind == JsonValueKind.Null) { - audio = null; + responseAudioReference = null; continue; } - audio = InternalChatCompletionRequestAssistantMessageAudio.DeserializeInternalChatCompletionRequestAssistantMessageAudio(prop.Value, options); + responseAudioReference = ChatResponseAudioReference.DeserializeChatResponseAudioReference(prop.Value, options); continue; } if (true) @@ -133,7 +133,7 @@ internal static InternalFineTuneChatCompletionRequestAssistantMessage Deserializ participantName, toolCalls ?? new ChangeTrackingList(), functionCall, - audio); + responseAudioReference); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs index 85bdc8549..67114c758 100644 --- a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs +++ b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs @@ -14,7 +14,7 @@ public InternalFineTuneChatCompletionRequestAssistantMessage() { } - internal InternalFineTuneChatCompletionRequestAssistantMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, InternalChatCompletionRequestAssistantMessageAudio audio) : base(content, role, additionalBinaryDataProperties, refusal, participantName, toolCalls, functionCall, audio) + internal InternalFineTuneChatCompletionRequestAssistantMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, ChatResponseAudioReference responseAudioReference) : base(content, role, additionalBinaryDataProperties, refusal, participantName, toolCalls, functionCall, responseAudioReference) { } } diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index 77369458b..096e66a75 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -950,7 +950,7 @@ public static UserChatMessage UserChatMessage(ChatMessageContent content = defau return new UserChatMessage(content, Chat.ChatMessageRole.User, additionalBinaryDataProperties: null, participantName); } - public static AssistantChatMessage AssistantChatMessage(ChatMessageContent content = default, string refusal = default, string participantName = default, IEnumerable toolCalls = default, ChatFunctionCall functionCall = default, InternalChatCompletionRequestAssistantMessageAudio audio = default) + public static AssistantChatMessage AssistantChatMessage(ChatMessageContent content = default, string refusal = default, string participantName = default, IEnumerable toolCalls = default, ChatFunctionCall functionCall = default, ChatResponseAudioReference responseAudioReference = default) { toolCalls ??= new ChangeTrackingList(); @@ -962,7 +962,13 @@ public static AssistantChatMessage AssistantChatMessage(ChatMessageContent conte participantName, toolCalls?.ToList(), functionCall, - audio); + responseAudioReference); + } + + public static ChatResponseAudioReference ChatResponseAudioReference(string id = default) + { + + return new ChatResponseAudioReference(id, additionalBinaryDataProperties: null); } public static ChatToolCall ChatToolCall(string id = default, InternalChatCompletionMessageToolCallFunction function = default, Chat.ChatToolCallKind kind = default) @@ -1029,6 +1035,12 @@ public static ChatCompletion ChatCompletion(string id = default, string model = additionalBinaryDataProperties: null); } + public static ChatResponseAudio ChatResponseAudio(string id = default, DateTimeOffset expiresAt = default, BinaryData data = default, string transcript = default) + { + + return new ChatResponseAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties: null); + } + public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = default, float logProbability = default, ReadOnlyMemory? utf8Bytes = default, IEnumerable topLogProbabilities = default) { topLogProbabilities ??= new ChangeTrackingList(); @@ -1235,7 +1247,7 @@ public static ChatMessageContent ChatMessageContent() return new ChatMessageContent(additionalBinaryDataProperties: null); } - public static ChatMessageContentPart ChatMessageContentPart(Chat.ChatMessageContentPartKind kind = default, string text = default, InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default, string refusal = default, InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default, InternalChatCompletionResponseMessageAudio outputAudio = default, InternalChatCompletionMessageAudioChunk responseAudioUpdate = default, InternalChatCompletionRequestAssistantMessageAudio audioReference = default) + public static ChatMessageContentPart ChatMessageContentPart(Chat.ChatMessageContentPartKind kind = default, string text = default, InternalChatCompletionRequestMessageContentPartImageImageUrl imageUri = default, string refusal = default, InternalChatCompletionRequestMessageContentPartAudioInputAudio inputAudio = default) { return new ChatMessageContentPart( @@ -1244,9 +1256,6 @@ public static ChatMessageContentPart ChatMessageContentPart(Chat.ChatMessageCont imageUri, refusal, inputAudio, - outputAudio, - responseAudioUpdate, - audioReference, serializedAdditionalRawData: null); } diff --git a/.dotnet/tests/Chat/ChatSmokeTests.cs b/.dotnet/tests/Chat/ChatSmokeTests.cs index 618509ef2..3f2e90388 100644 --- a/.dotnet/tests/Chat/ChatSmokeTests.cs +++ b/.dotnet/tests/Chat/ChatSmokeTests.cs @@ -537,7 +537,7 @@ public void SerializeRefusalMessages() public void SerializeAudioThings() { // User audio input: wire-correlated ("real") content parts should cleanly serialize/deserialize - ChatMessageContentPart inputAudioContentPart = ChatMessageContentPart.CreateAudioPart( + ChatMessageContentPart inputAudioContentPart = ChatMessageContentPart.CreateInputAudioPart( BinaryData.FromBytes([0x4, 0x2]), ChatInputAudioFormat.Mp3); Assert.That(inputAudioContentPart, Is.Not.Null); @@ -546,16 +546,6 @@ public void SerializeAudioThings() ChatMessageContentPart deserializedInputAudioContentPart = ModelReaderWriter.Read(serializedInputAudioContentPart); Assert.That(deserializedInputAudioContentPart.AudioBytes.ToArray()[1], Is.EqualTo(0x2)); - // Synthetic content parts wrapping input audio references should throw - ChatMessageContentPart audioReferenceContentPart = ChatMessageContentPart.CreateAudioPart("audio-id"); - Assert.Throws(() => ModelReaderWriter.Write(audioReferenceContentPart)); - - // That same synthetic content part should serialize to the right place when added to a message - AssistantChatMessage messageWithAudioReference = new([audioReferenceContentPart]); - BinaryData serializedMessageWithAudioReference = ModelReaderWriter.Write(messageWithAudioReference); - Assert.That(serializedMessageWithAudioReference.ToString(), Does.Contain(@"""audio"":{""id"":""audio-id""}")); - Assert.That(serializedMessageWithAudioReference.ToString(), Does.Not.Contain(@"""content""")); - AssistantChatMessage message = ModelReaderWriter.Read(BinaryData.FromBytes(""" { "role": "assistant", @@ -564,13 +554,14 @@ public void SerializeAudioThings() } } """u8.ToArray())); - Assert.That(message.Content, Has.Count.EqualTo(1)); - Assert.That(message.Content[0].AudioCorrelationId, Is.EqualTo("audio_correlated_id_1234")); + Assert.That(message.Content, Has.Count.EqualTo(0)); + Assert.That(message.ResponseAudioReference, Is.Not.Null); + Assert.That(message.ResponseAudioReference.Id, Is.EqualTo("audio_correlated_id_1234")); string serializedMessage = ModelReaderWriter.Write(message).ToString(); Assert.That(serializedMessage, Does.Contain(@"""audio"":{""id"":""audio_correlated_id_1234""}")); AssistantChatMessage ordinaryTextAssistantMessage = new(["This was a message from the assistant"]); - ordinaryTextAssistantMessage.Content.Add(ChatMessageContentPart.CreateAudioPart("extra-audio-id")); + ordinaryTextAssistantMessage.ResponseAudioReference = new("extra-audio-id"); BinaryData serializedLateAudioMessage = ModelReaderWriter.Write(ordinaryTextAssistantMessage); Assert.That(serializedLateAudioMessage.ToString(), Does.Contain("was a message")); Assert.That(serializedLateAudioMessage.ToString(), Does.Contain("extra-audio-id")); @@ -621,14 +612,14 @@ public void SerializeAudioThings() """u8.ToArray()); ChatCompletion audioCompletion = ModelReaderWriter.Read(rawAudioResponse); Assert.That(audioCompletion, Is.Not.Null); - - // Synthetic response audio content parts (reprojecting internal choices[*].message.audio) should throw when - // attempting independent serialization - Assert.Throws(() => ModelReaderWriter.Write(audioCompletion.Content[0])); - + Assert.That(audioCompletion.Content, Has.Count.EqualTo(0)); + Assert.That(audioCompletion.ResponseAudio, Is.Not.Null); + Assert.That(audioCompletion.ResponseAudio.Id, Is.EqualTo("audio_6725224ac62481908ab55dc283289d87")); + Assert.That(audioCompletion.ResponseAudio.Data, Is.Not.Null); + Assert.That(audioCompletion.ResponseAudio.Transcript, Is.Not.Null.And.Not.Empty); + AssistantChatMessage audioHistoryMessage = new(audioCompletion); - BinaryData serializedAudioHistoryMessage = ModelReaderWriter.Write(audioHistoryMessage); - Console.WriteLine(serializedAudioHistoryMessage.ToString()); + Assert.That(audioHistoryMessage.ResponseAudioReference?.Id, Is.EqualTo(audioCompletion.ResponseAudio.Id)); } [Test] diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index 8c9ea8414..3a6da8060 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -373,12 +373,12 @@ public async Task ChatWithAudio() string helloWorldAudioPath = Path.Join("Assets", "audio_hello_world.mp3"); BinaryData helloWorldAudioBytes = BinaryData.FromBytes(File.ReadAllBytes(helloWorldAudioPath)); - ChatMessageContentPart helloWorldAudioContentPart = ChatMessageContentPart.CreateAudioPart( + ChatMessageContentPart helloWorldAudioContentPart = ChatMessageContentPart.CreateInputAudioPart( helloWorldAudioBytes, ChatInputAudioFormat.Mp3); - string whatsTheWeatherAudioPath = Path.Join("Assets", "whats_the_weather_pcm16_24khz_mono.wav"); + string whatsTheWeatherAudioPath = Path.Join("Assets", "realtime_whats_the_weather_pcm16_24khz_mono.wav"); BinaryData whatsTheWeatherAudioBytes = BinaryData.FromBytes(File.ReadAllBytes(whatsTheWeatherAudioPath)); - ChatMessageContentPart whatsTheWeatherAudioContentPart = ChatMessageContentPart.CreateAudioPart( + ChatMessageContentPart whatsTheWeatherAudioContentPart = ChatMessageContentPart.CreateInputAudioPart( whatsTheWeatherAudioBytes, ChatInputAudioFormat.Wav); @@ -391,40 +391,42 @@ public async Task ChatWithAudio() ChatCompletion completion = await client.CompleteChatAsync(messages, options); Assert.That(completion, Is.Not.Null); - Assert.That(completion.Content, Is.Not.Null); - Assert.That(completion.Content[0].Kind, Is.EqualTo(ChatMessageContentPartKind.Audio)); - Assert.That(completion.Content[0].AudioCorrelationId, Is.Not.Null.And.Not.Empty); - Assert.That(completion.Content[0].AudioBytes, Is.Not.Null); - Assert.That(completion.Content[0].AudioTranscript, Is.Not.Null.And.Not.Empty); + Assert.That(completion.Content, Has.Count.EqualTo(0)); + + ChatResponseAudio responseAudio = completion.ResponseAudio; + Assert.That(responseAudio, Is.Not.Null); + Assert.That(responseAudio.Id, Is.Not.Null.And.Not.Empty); + Assert.That(responseAudio.Data, Is.Not.Null); + Assert.That(responseAudio.Transcript, Is.Not.Null.And.Not.Empty); AssistantChatMessage audioHistoryMessage = ChatMessage.CreateAssistantMessage(completion); Assert.That(audioHistoryMessage, Is.InstanceOf()); - Assert.That(audioHistoryMessage.Content, Is.Not.Null.And.Not.Empty); - Assert.That(audioHistoryMessage.Content[0].Kind, Is.EqualTo(ChatMessageContentPartKind.Audio)); - Assert.That(audioHistoryMessage.Content[0].AudioCorrelationId, Is.EqualTo(completion.Content[0].AudioCorrelationId)); - Assert.That(audioHistoryMessage.Content[0].AudioBytes, Is.Null); + Assert.That(audioHistoryMessage.Content, Has.Count.EqualTo(0)); + + Assert.That(audioHistoryMessage.ResponseAudioReference?.Id, Is.EqualTo(completion.ResponseAudio.Id)); messages.Add(audioHistoryMessage); messages.Add( new UserChatMessage( [ "Please answer the following spoken question:", - ChatMessageContentPart.CreateAudioPart(whatsTheWeatherAudioBytes, ChatInputAudioFormat.Wav), + ChatMessageContentPart.CreateInputAudioPart(whatsTheWeatherAudioBytes, ChatInputAudioFormat.Wav), ])); string streamedCorrelationId = null; using MemoryStream responseAudioStream = new(); await foreach (StreamingChatCompletionUpdate update in client.CompleteChatStreamingAsync(messages, options)) { - Assert.That(update.ContentUpdate, Is.Not.Null); - if (update.ContentUpdate.Count > 0) + Assert.That(update.ContentUpdate, Has.Count.EqualTo(0)); + ChatResponseAudio responseAudioUpdate = update.ResponseAudio; + if (responseAudioUpdate is not null) { - if (!string.IsNullOrEmpty(update.ContentUpdate[0].AudioCorrelationId)) + if (responseAudioUpdate.Id is not null) { - Assert.That(streamedCorrelationId, Is.Null.Or.EqualTo(update.ContentUpdate[0].AudioCorrelationId)); - streamedCorrelationId = update.ContentUpdate[0].AudioCorrelationId; + Assert.That(streamedCorrelationId, Is.Null.Or.EqualTo(responseAudioUpdate.Id)); + streamedCorrelationId = responseAudioUpdate.Id; } - responseAudioStream.Write(update.ContentUpdate[0].AudioBytes); + responseAudioStream.Write(responseAudioUpdate.Data); } } Assert.That(streamedCorrelationId, Is.Not.Null.And.Not.Empty); diff --git a/.scripts/Edit-Serialization.ps1 b/.scripts/Edit-Serialization.ps1 index 18b296356..9e1be0160 100644 --- a/.scripts/Edit-Serialization.ps1 +++ b/.scripts/Edit-Serialization.ps1 @@ -45,23 +45,23 @@ Update-In-File-With-Retry ` -FilePath "$directory\InternalChatCompletionStreamResponseDelta.Serialization.cs" ` -SearchPatternLines @( "return new InternalChatCompletionStreamResponseDelta\(" - " audio," " functionCall," " toolCalls \?\? new ChangeTrackingList\(\)," " refusal," " role," " content," + " audio," " additionalBinaryDataProperties\);" ) ` -ReplacePatternLines @( "// CUSTOM: Initialize Content collection property." "return new InternalChatCompletionStreamResponseDelta(" - " audio," " functionCall," " toolCalls ?? new ChangeTrackingList()," " refusal," " role," " content ?? new ChatMessageContent()," + " audio," " additionalBinaryDataProperties);" ) ` -OutputIndentation 12 ` @@ -79,6 +79,34 @@ Update-In-File-With-Retry ` -OutputIndentation 12 ` -RequirePresence +Update-In-File-With-Retry ` + -FilePath "$directory\AssistantChatMessage.Serialization.cs" ` + -SearchPatternLines @( + "return new AssistantChatMessage\(" + " content," + " role," + " additionalBinaryDataProperties," + " refusal," + " participantName," + " toolCalls \?\? new ChangeTrackingList\(\)," + " functionCall," + " responseAudioReference\);" + ) ` + -ReplacePatternLines @( + "// CUSTOM: Initialize Content collection property." + "return new AssistantChatMessage(" + " content ?? new ChatMessageContent()," + " role," + " additionalBinaryDataProperties," + " refusal," + " participantName," + " toolCalls ?? new ChangeTrackingList()," + " functionCall," + " responseAudioReference);" + ) ` + -OutputIndentation 12 ` + -RequirePresence + Update-In-File-With-Retry ` -FilePath "$directory\FunctionChatMessage.Serialization.cs" ` -SearchPatternLines @( @@ -150,7 +178,7 @@ Update-In-File-With-Retry ` " participantName," " toolCalls \?\? new ChangeTrackingList\(\)," " functionCall," - " audio\);" + " responseAudioReference\);" ) ` -ReplacePatternLines @( "// CUSTOM: Initialize Content collection property." @@ -162,7 +190,7 @@ Update-In-File-With-Retry ` " participantName," " toolCalls ?? new ChangeTrackingList()," " functionCall," - " audio);" + " responseAudioReference);" ) ` -OutputIndentation 12 ` -RequirePresence From fc923385655cd5f9becd5abc46c1a3f622f032f4 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 15 Jan 2025 17:44:42 -0800 Subject: [PATCH 06/44] add a minimal, explicit test for the latest o1 model --- .dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json | 2 +- .../tests/Assets/playback_test_config.json | 5 +++++ .../sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json index 7bb268d2c..56b1f7e14 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "dotnet.azure/openai/Azure.AI.OpenAI", - "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_9b6eb979c1" + "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_d24fa6bfaa" } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json index cfbe142ab..a628f67ed 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json @@ -24,6 +24,11 @@ "key": "Sanitized", "deployment": "gpt-4o-0806" }, + "chat_o1": { + "endpoint": "https://Sanitized.openai.azure.com/", + "key": "Sanitized", + "deployment": "o1" + }, "chat_with_async_filter": { "endpoint": "https://Sanitized.openai.azure.com/", "key": "Sanitized", diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs index 8016feb52..5447a6367 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs @@ -725,6 +725,17 @@ in client.CompleteChatStreamingAsync( #region Tests for interim o1 model support regarding new max_completion_tokens + [RecordedTest] + public async Task ChatWithO1Works() + { + IConfiguration testConfig = TestConfig.GetConfig("chat_o1")!; + + ChatClient client = GetTestClient(testConfig); + + ChatCompletion completion = await client.CompleteChatAsync([ChatMessage.CreateUserMessage("Hello, world!")]); + Assert.That(completion, Is.Not.Null); + } + #endregion #region Helper methods From 1dc82853d1b4f31babb5936b2990add8f76d448e Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 16 Jan 2025 14:58:37 -0800 Subject: [PATCH 07/44] improve AOAI parity spec generation (code no-op) --- ...pi3-azure-openai-2024-06-01-generated.yaml | 2380 ++++++++-------- ...e-openai-2024-08-01-preview-generated.yaml | 2288 +++++++++------- ...e-openai-2024-09-01-preview-generated.yaml | 2288 +++++++++------- ...e-openai-2024-10-01-preview-generated.yaml | 2288 +++++++++------- ...pi3-azure-openai-2024-10-21-generated.yaml | 2378 ++++++++-------- ...e-openai-2024-12-01-preview-generated.yaml | 2392 +++++++++-------- .typespec.azure/chat/models.request.tsp | 10 +- .typespec.azure/chat/models.response.tsp | 24 +- .typespec.azure/chat/operations.tsp | 5 +- 9 files changed, 7754 insertions(+), 6299 deletions(-) diff --git a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml index d6983afce..aa0d3d740 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml @@ -7,27 +7,6 @@ tags: - name: Images - name: Assistants paths: - /chat/completions: - post: - operationId: createChatCompletion - parameters: [] - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' - - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' - tags: - - Chat - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/AzureCreateChatCompletionRequest' /deployments/{deploymentId}/images/generations: post: operationId: ImageGenerations_Create @@ -86,6 +65,32 @@ paths: application/json: schema: $ref: '#/components/schemas/OpenAI.CreateMessageRequest' + /{deployment_id}/chat/completions: + post: + operationId: createChatCompletion + parameters: + - name: deployment_id + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' + tags: + - Chat + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AzureCreateChatCompletionRequest' security: - ApiKeyAuth: [] - OAuth2Auth: @@ -432,6 +437,43 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. + AzureCompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + - completion_tokens_details + - prompt_tokens_details + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + reasoning_tokens: + type: integer + format: int32 + required: + - reasoning_tokens + prompt_tokens_details: + type: object + properties: + cached_tokens: + type: integer + format: int32 + required: + - cached_tokens AzureContentFilterBlocklistIdResult: type: object required: @@ -835,160 +877,442 @@ components: description: Represents a data source configuration that will use an Azure CosmosDB resource. AzureCreateChatCompletionRequest: type: object + required: + - messages properties: - data_sources: - type: array - items: - $ref: '#/components/schemas/AzureChatDataSource' - description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionRequest' - description: |- - The extended request model for chat completions against the Azure OpenAI service. - This adds the ability to provide data sources for the On Your Data feature. - AzureCreateChatCompletionResponse: - type: object - properties: - prompt_filter_results: + messages: type: array items: - type: object - properties: - prompt_index: - type: integer - format: int32 - description: The index of the input prompt that this content filter result corresponds to. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter results associated with the indexed input prompt. - required: - - prompt_index - - content_filter_results - description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionResponse' - description: |- - The extended top-level chat completion response model for the Azure OpenAI service. - This model adds Responsible AI content filter annotations for prompt input. - AzureImage: - type: object - required: - - prompt_filter_results - - content_filter_results - properties: - prompt_filter_results: - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - content_filter_results: - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' - allOf: - - $ref: '#/components/schemas/OpenAI.Image' - AzureMachineLearningIndexChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - azure_ml_index - description: The discriminated type identifier, which is always 'azure_ml_index'. - parameters: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - role_information: - type: string - description: |- - Additional instructions for the model to inform how it should behave and any context it should reference when - generating a response. You can describe the assistant's personality and tell it how to format responses. - This is limited to 100 tokens and counts against the overall token limit. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - project_resource_id: - type: string - description: The ID of the Azure Machine Learning index project to use. - name: - type: string - description: The name of the Azure Machine Learning index to use. - version: - type: string - description: The version of the vector index to use. - filter: - type: string - description: A search filter, which is only applicable if the vector index is of the 'AzureSearch' type. - required: - - authentication - - project_resource_id - - name - - version - description: The parameter information to control the use of the Azure Machine Learning Index data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Machine Learning vector index. - AzureOpenAIChatError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: type: object - properties: + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + data_sources: + type: array + items: + $ref: '#/components/schemas/AzureChatDataSource' + description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. + description: |- + The extended request model for chat completions against the Azure OpenAI service. + This adds the ability to provide data sources for the On Your Data feature. + AzureCreateChatCompletionResponse: + type: object + required: + - id + - choices + - created + - model + - object + - usage + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + usage: + $ref: '#/components/schemas/AzureCompletionUsage' + prompt_filter_results: + type: array + items: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt that this content filter result corresponds to. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter results associated with the indexed input prompt. + required: + - prompt_index + - content_filter_results + description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. + description: |- + The extended top-level chat completion response model for the Azure OpenAI service. + This model adds Responsible AI content filter annotations for prompt input. + AzureImage: + type: object + required: + - prompt_filter_results + - content_filter_results + properties: + prompt_filter_results: + $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + content_filter_results: + $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + allOf: + - $ref: '#/components/schemas/OpenAI.Image' + AzureMachineLearningIndexChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_ml_index + description: The discriminated type identifier, which is always 'azure_ml_index'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + role_information: + type: string + description: |- + Additional instructions for the model to inform how it should behave and any context it should reference when + generating a response. You can describe the assistant's personality and tell it how to format responses. + This is limited to 100 tokens and counts against the overall token limit. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + project_resource_id: + type: string + description: The ID of the Azure Machine Learning index project to use. + name: + type: string + description: The name of the Azure Machine Learning index to use. + version: + type: string + description: The version of the vector index to use. + filter: + type: string + description: A search filter, which is only applicable if the vector index is of the 'AzureSearch' type. + required: + - authentication + - project_resource_id + - name + - version + description: The parameter information to control the use of the Azure Machine Learning Index data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Machine Learning vector index. + AzureOpenAIChatError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: code: type: string enum: @@ -1030,180 +1354,490 @@ components: code: type: string enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI image generation request. + AzureOpenAIDalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIDalleError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIServiceApiVersion: + type: string + enum: + - 2024-06-01 + - 2024-08-01-preview + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 + - 2024-12-01-preview + description: Known service API versions for Azure OpenAI. + AzureSearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_search + description: The discriminated type identifier, which is always 'azure_search'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + role_information: + type: string + description: |- + Additional instructions for the model to inform how it should behave and any context it should reference when + generating a response. You can describe the assistant's personality and tell it how to format responses. + This is limited to 100 tokens and counts against the overall token limit. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + description: The absolute endpoint path for the Azure Search resource to use. + index_name: + type: string + description: The name of the index to use, as specified in the Azure Search resource. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: The authentication mechanism to use with Azure Search. + fields_mapping: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + items: + type: string + description: The names of index fields that should be treated as content. + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + items: + type: string + description: The names of fields that represent vector data. + image_vector_fields: + type: array + items: + type: string + description: The names of fields that represent image vector data. + description: The field mappings to use with the Azure Search resource. + query_type: + type: string + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI image generation request. - AzureOpenAIDalleErrorResponse: + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionTokenLogprobBytesItem: + type: array + items: + type: integer + format: int32 + CompletionUsageCommonBase: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + description: Usage statistics for the completion request. + CreateChatCompletionRequestCommonBase: type: object + required: + - messages properties: - error: - $ref: '#/components/schemas/AzureOpenAIDalleError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - description: Known service API versions for Azure OpenAI. - AzureSearchChatDataSource: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + CreateChatCompletionResponseCommonBase: type: object required: - - type - - parameters + - id + - choices + - created + - model + - object properties: - type: + id: type: string - enum: - - azure_search - description: The discriminated type identifier, which is always 'azure_search'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - role_information: - type: string - description: |- - Additional instructions for the model to inform how it should behave and any context it should reference when - generating a response. You can describe the assistant's personality and tell it how to format responses. - This is limited to 100 tokens and counts against the overall token limit. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: type: string enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - format: uri - description: The absolute endpoint path for the Azure Search resource to use. - index_name: - type: string - description: The name of the index to use, as specified in the Azure Search resource. - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - description: The authentication mechanism to use with Azure Search. - fields_mapping: - type: object - properties: - title_field: - type: string - description: The name of the index field to use as a title. - url_field: - type: string - description: The name of the index field to use as a URL. - filepath_field: - type: string - description: The name of the index field to use as a filepath. - content_fields: - type: array - items: - type: string - description: The names of index fields that should be treated as content. - content_fields_separator: - type: string - description: The separator pattern that content fields should use. - vector_fields: - type: array - items: - type: string - description: The names of fields that represent vector data. - image_vector_fields: - type: array - items: - type: string - description: The names of fields that represent image vector data. - description: The field mappings to use with the Azure Search resource. - query_type: - type: string - enum: - - simple - - semantic - - vector - - vector_simple_hybrid - - vector_semantic_hybrid - description: The query type for the Azure Search resource to use. - semantic_configuration: - type: string - description: Additional semantic configuration for the query. - filter: - type: string - description: A filter to apply to the search. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - description: |- - The vectorization source to use with Azure Search. - Supported sources for Azure Search include endpoint, deployment name, and integrated. - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Azure Search data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Search resource. - ChatCompletionMessageToolCallsItem: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' - description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -1540,259 +2174,9 @@ components: description: The role of the messages author, in this case `assistant`. name: type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - nullable: true - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestAssistantMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestFunctionMessage: - type: object - required: - - role - - content - - name - properties: - role: - type: string - enum: - - function - description: The role of the messages author, in this case `function`. - content: - type: string - nullable: true - description: The contents of the function message. - name: - type: string - description: The name of the function to call. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - deprecated: true - OpenAI.ChatCompletionRequestMessage: - type: object - required: - - role - properties: - role: - type: string - description: The role of the author of this message. - discriminator: - propertyName: role - mapping: - system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' - user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' - assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' - tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' - function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestMessageContentPartImage: - type: object - required: - - type - - image_url - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - format: uri - description: Either a URL of the image or the base64 encoded image data. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). - default: auto - required: - - url - OpenAI.ChatCompletionRequestMessageContentPartRefusal: - type: object - required: - - type - - refusal - properties: - type: - type: string - enum: - - refusal - description: The type of the content part. - refusal: - type: string - description: The refusal message generated by the model. - OpenAI.ChatCompletionRequestMessageContentPartText: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: The type of the content part. - text: - type: string - description: The text content. - OpenAI.ChatCompletionRequestSystemMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' - description: The contents of the system message. - role: - type: string - enum: - - system - description: The role of the messages author, in this case `system`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestSystemMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestToolMessage: - type: object - required: - - role - - content - - tool_call_id - properties: - role: - type: string - enum: - - tool - description: The role of the messages author, in this case `tool`. - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' - description: The contents of the tool message. - tool_call_id: - type: string - description: Tool call that this message is responding to. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestToolMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestUserMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' - description: The contents of the user message. - x-oaiExpandable: true - role: - type: string - enum: - - user - description: The role of the messages author, in this case `user`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestUserMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' - x-oaiExpandable: true - OpenAI.ChatCompletionResponseMessage: - type: object - required: - - content - - refusal - - role - properties: - content: - type: string - nullable: true - description: The contents of the message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - role: - type: string - enum: - - assistant - description: The role of the author of this message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamOptions: - type: object - properties: - include_usage: - type: boolean - description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' - description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - content: - type: string - nullable: true - description: The contents of the chunk message. + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: type: object properties: @@ -1800,564 +2184,418 @@ components: type: string arguments: type: string + required: + - name + - arguments + nullable: true description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. - OpenAI.ChatCompletionTokenLogprob: - type: object - required: - - token - - logprob - - bytes - - top_logprobs - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - top_logprobs: - type: array - items: - type: object - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: array - items: - type: integer - format: int32 - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - required: - - token - - logprob - - bytes - description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. - OpenAI.ChatCompletionTool: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestAssistantMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestFunctionMessage: type: object required: - - type - - function + - role + - content + - name properties: - type: + role: type: string enum: - function - description: The type of the tool. Currently, only `function` is supported. - function: - $ref: '#/components/schemas/OpenAI.FunctionObject' - OpenAI.ChatCompletionToolChoiceOption: - anyOf: - - type: string - enum: - - none - - auto - - required - - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' - description: |- - Controls which (if any) tool is called by the model. - `none` means the model will not call any tool and instead generates a message. - `auto` means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools. - Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - `none` is the default when no tools are present. `auto` is the default if tools are present. - x-oaiExpandable: true - OpenAI.ChatResponseFormat: + description: The role of the messages author, in this case `function`. + content: + type: string + nullable: true + description: The contents of the function message. + name: + type: string + description: The name of the function to call. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + deprecated: true + OpenAI.ChatCompletionRequestMessage: type: object required: - - type + - role properties: - type: + role: type: string + description: The role of the author of this message. discriminator: - propertyName: type + propertyName: role mapping: - text: '#/components/schemas/OpenAI.ChatResponseFormatText' - json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' - json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' - OpenAI.ChatResponseFormatJsonObject: + system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' + assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' + tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' + function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: - type + - image_url properties: type: type: string enum: - - json_object - description: 'The type of response format being defined: `json_object`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatJsonSchema: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: Either a URL of the image or the base64 encoded image data. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + default: auto + required: + - url + OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: - type - - json_schema + - refusal properties: type: type: string enum: - - json_schema - description: 'The type of response format being defined: `json_schema`' - json_schema: - type: object - properties: - description: - type: string - description: A description of what the response format is for, used by the model to determine how to respond in the format. - name: - type: string - description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - schema: - $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). - default: false - required: - - name - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatText: + - refusal + description: The type of the content part. + refusal: + type: string + description: The refusal message generated by the model. + OpenAI.ChatCompletionRequestMessageContentPartText: type: object required: - type + - text properties: type: type: string enum: - text - description: 'The type of response format being defined: `text`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.CompletionUsage: + description: The type of the content part. + text: + type: string + description: The text content. + OpenAI.ChatCompletionRequestSystemMessage: type: object required: - - completion_tokens - - prompt_tokens - - total_tokens + - content + - role properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens generated by the model. - reasoning_tokens: - type: integer - format: int32 - description: Tokens generated by the model for reasoning. - required: - - audio_tokens - - reasoning_tokens - description: Breakdown of tokens used in a completion. - prompt_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens present in the prompt. - cached_tokens: - type: integer - format: int32 - description: Cached tokens present in the prompt. - required: - - audio_tokens - - cached_tokens - description: Breakdown of tokens used in the prompt. - description: Usage statistics for the completion request. - OpenAI.CreateChatCompletionRequest: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + description: The contents of the system message. + role: + type: string + enum: + - system + description: The role of the messages author, in this case `system`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestSystemMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestToolMessage: type: object required: - - messages - - model + - role + - content + - tool_call_id properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - model: + role: + type: string + enum: + - tool + description: The role of the messages author, in this case `tool`. + content: anyOf: - type: string - - type: string - enum: - - o1-preview - - o1-preview-2024-09-12 - - o1-mini - - o1-mini-2024-09-12 - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - - chatgpt-4o-latest - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0301 - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. - x-oaiTypeLabel: string - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - service_tier: + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' + description: The contents of the tool message. + tool_call_id: type: string - enum: - - auto - - default - nullable: true - description: |- - Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. - default: auto - stop: + description: Tool call that this message is responding to. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestToolMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestUserMessage: + type: object + required: + - content + - role + properties: + content: anyOf: - type: string - type: array items: - type: string + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' + description: The contents of the user message. + x-oaiExpandable: true + role: + type: string + enum: + - user + description: The role of the messages author, in this case `user`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestUserMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + x-oaiExpandable: true + OpenAI.ChatCompletionResponseMessage: + type: object + required: + - content + - refusal + - role + properties: + content: + type: string nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean + description: The contents of the message. + refusal: + type: string nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: + description: The refusal message generated by the model. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + role: + type: string + enum: + - assistant + description: The role of the author of this message. + function_call: type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + description: A chat completion message generated by the model. + OpenAI.ChatCompletionStreamOptions: + type: object + properties: + include_usage: type: boolean - default: true - user: + description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' + description: 'Options for streaming response. Only set this when you set `stream: true`.' + OpenAI.ChatCompletionStreamResponseDelta: + type: object + properties: + content: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + nullable: true + description: The contents of the chunk message. function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - x-oaiExpandable: true - functions: + tool_calls: type: array items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - OpenAI.CreateChatCompletionResponse: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + description: A chat completion delta generated by streamed model responses. + OpenAI.ChatCompletionTokenLogprob: type: object required: - - id - - choices - - created - - model - - object + - token + - logprob + - bytes + - top_logprobs properties: - id: + token: type: string - description: A unique identifier for the chat completion. - choices: + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + top_logprobs: type: array items: type: object properties: - finish_reason: + token: type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: array + items: + type: integer + format: int32 nullable: true - description: Log probability information for the choice. + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: + - token + - logprob + - bytes + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + OpenAI.ChatCompletionTool: + type: object + required: + - type + - function + properties: + type: type: string - description: The model used for the chat completion. - service_tier: + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + OpenAI.ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - auto + - required + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' + description: |- + Controls which (if any) tool is called by the model. + `none` means the model will not call any tool and instead generates a message. + `auto` means the model can pick between generating a message or calling one or more tools. + `required` means the model must call one or more tools. + Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + + `none` is the default when no tools are present. `auto` is the default if tools are present. + x-oaiExpandable: true + OpenAI.ChatResponseFormat: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/OpenAI.ChatResponseFormatText' + json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' + json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' + OpenAI.ChatResponseFormatJsonObject: + type: object + required: + - type + properties: + type: type: string enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: + - json_object + description: 'The type of response format being defined: `json_object`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatJsonSchema: + type: object + required: + - type + - json_schema + properties: + type: type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: + enum: + - json_schema + description: 'The type of response format being defined: `json_schema`' + json_schema: + type: object + properties: + description: + type: string + description: A description of what the response format is for, used by the model to determine how to respond in the format. + name: + type: string + description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + default: false + required: + - name + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatText: + type: object + required: + - type + properties: + type: type: string enum: - - chat.completion - description: The object type, which is always `chat.completion`. - usage: - $ref: '#/components/schemas/OpenAI.CompletionUsage' - description: Represents a chat completion response returned by model, based on the provided input. + - text + description: 'The type of response format being defined: `text`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml index 95f71ab9c..bf4844b68 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml @@ -7,27 +7,6 @@ tags: - name: Images - name: Assistants paths: - /chat/completions: - post: - operationId: createChatCompletion - parameters: [] - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' - - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' - tags: - - Chat - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/AzureCreateChatCompletionRequest' /deployments/{deploymentId}/images/generations: post: operationId: ImageGenerations_Create @@ -86,6 +65,32 @@ paths: application/json: schema: $ref: '#/components/schemas/OpenAI.CreateMessageRequest' + /{deployment_id}/chat/completions: + post: + operationId: createChatCompletion + parameters: + - name: deployment_id + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' + tags: + - Chat + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AzureCreateChatCompletionRequest' security: - ApiKeyAuth: [] - OAuth2Auth: @@ -464,6 +469,43 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. + AzureCompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + - completion_tokens_details + - prompt_tokens_details + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + reasoning_tokens: + type: integer + format: int32 + required: + - reasoning_tokens + prompt_tokens_details: + type: object + properties: + cached_tokens: + type: integer + format: int32 + required: + - cached_tokens AzureContentFilterBlocklistIdResult: type: object required: @@ -861,282 +903,874 @@ components: description: Represents a data source configuration that will use an Azure CosmosDB resource. AzureCreateChatCompletionRequest: type: object + required: + - messages properties: - data_sources: - type: array - items: - $ref: '#/components/schemas/AzureChatDataSource' - description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionRequest' - description: |- - The extended request model for chat completions against the Azure OpenAI service. - This adds the ability to provide data sources for the On Your Data feature. - AzureCreateChatCompletionResponse: - type: object - properties: - prompt_filter_results: + messages: type: array items: - type: object - properties: - prompt_index: - type: integer - format: int32 - description: The index of the input prompt that this content filter result corresponds to. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter results associated with the indexed input prompt. - required: - - prompt_index - - content_filter_results - description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionResponse' - description: |- - The extended top-level chat completion response model for the Azure OpenAI service. - This model adds Responsible AI content filter annotations for prompt input. - AzureImage: - type: object - required: - - prompt_filter_results - - content_filter_results - properties: - prompt_filter_results: - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - content_filter_results: - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' - allOf: - - $ref: '#/components/schemas/OpenAI.Image' - AzureOpenAIChatError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: - type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI chat completion request. - AzureOpenAIChatErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIChatError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIDalleError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI image generation request. - AzureOpenAIDalleErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIDalleError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - description: Known service API versions for Azure OpenAI. - AzureSearchChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - azure_search - description: The discriminated type identifier, which is always 'azure_search'. - parameters: + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array items: type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - format: uri - description: The absolute endpoint path for the Azure Search resource to use. - index_name: - type: string - description: The name of the index to use, as specified in the Azure Search resource. - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - description: The authentication mechanism to use with Azure Search. - fields_mapping: - type: object - properties: - title_field: - type: string - description: The name of the index field to use as a title. - url_field: - type: string - description: The name of the index field to use as a URL. - filepath_field: - type: string - description: The name of the index field to use as a filepath. - content_fields: - type: array - items: - type: string - description: The names of index fields that should be treated as content. - content_fields_separator: - type: string - description: The separator pattern that content fields should use. - vector_fields: - type: array - items: - type: string - description: The names of fields that represent vector data. - image_vector_fields: - type: array - items: - type: string - description: The names of fields that represent image vector data. - description: The field mappings to use with the Azure Search resource. - query_type: - type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string enum: - - simple - - semantic - - vector - - vector_simple_hybrid - - vector_semantic_hybrid - description: The query type for the Azure Search resource to use. - semantic_configuration: - type: string - description: Additional semantic configuration for the query. - filter: - type: string - description: A filter to apply to the search. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' - description: |- - The vectorization source to use with Azure Search. - Supported sources for Azure Search include endpoint, deployment name, and integrated. - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Azure Search data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Search resource. - ChatCompletionMessageToolCallsItem: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' - description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + data_sources: + type: array + items: + $ref: '#/components/schemas/AzureChatDataSource' + description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. + description: |- + The extended request model for chat completions against the Azure OpenAI service. + This adds the ability to provide data sources for the On Your Data feature. + AzureCreateChatCompletionResponse: + type: object + required: + - id + - choices + - created + - model + - object + - usage + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + usage: + $ref: '#/components/schemas/AzureCompletionUsage' + prompt_filter_results: + type: array + items: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt that this content filter result corresponds to. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter results associated with the indexed input prompt. + required: + - prompt_index + - content_filter_results + description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. + description: |- + The extended top-level chat completion response model for the Azure OpenAI service. + This model adds Responsible AI content filter annotations for prompt input. + AzureImage: + type: object + required: + - prompt_filter_results + - content_filter_results + properties: + prompt_filter_results: + $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + content_filter_results: + $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + allOf: + - $ref: '#/components/schemas/OpenAI.Image' + AzureOpenAIChatError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI chat completion request. + AzureOpenAIChatErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIChatError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIDalleError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI image generation request. + AzureOpenAIDalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIDalleError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIServiceApiVersion: + type: string + enum: + - 2024-06-01 + - 2024-08-01-preview + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 + - 2024-12-01-preview + description: Known service API versions for Azure OpenAI. + AzureSearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_search + description: The discriminated type identifier, which is always 'azure_search'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + description: The absolute endpoint path for the Azure Search resource to use. + index_name: + type: string + description: The name of the index to use, as specified in the Azure Search resource. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: The authentication mechanism to use with Azure Search. + fields_mapping: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + items: + type: string + description: The names of index fields that should be treated as content. + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + items: + type: string + description: The names of fields that represent vector data. + image_vector_fields: + type: array + items: + type: string + description: The names of fields that represent image vector data. + description: The field mappings to use with the Azure Search resource. + query_type: + type: string + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: + type: string + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionTokenLogprobBytesItem: + type: array + items: + type: integer + format: int32 + CompletionUsageCommonBase: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + description: Usage statistics for the completion request. + CreateChatCompletionRequestCommonBase: + type: object + required: + - messages + properties: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + CreateChatCompletionResponseCommonBase: + type: object + required: + - id + - choices + - created + - model + - object + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -1588,259 +2222,9 @@ components: description: The role of the messages author, in this case `assistant`. name: type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - nullable: true - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestAssistantMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestFunctionMessage: - type: object - required: - - role - - content - - name - properties: - role: - type: string - enum: - - function - description: The role of the messages author, in this case `function`. - content: - type: string - nullable: true - description: The contents of the function message. - name: - type: string - description: The name of the function to call. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - deprecated: true - OpenAI.ChatCompletionRequestMessage: - type: object - required: - - role - properties: - role: - type: string - description: The role of the author of this message. - discriminator: - propertyName: role - mapping: - system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' - user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' - assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' - tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' - function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestMessageContentPartImage: - type: object - required: - - type - - image_url - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - format: uri - description: Either a URL of the image or the base64 encoded image data. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). - default: auto - required: - - url - OpenAI.ChatCompletionRequestMessageContentPartRefusal: - type: object - required: - - type - - refusal - properties: - type: - type: string - enum: - - refusal - description: The type of the content part. - refusal: - type: string - description: The refusal message generated by the model. - OpenAI.ChatCompletionRequestMessageContentPartText: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: The type of the content part. - text: - type: string - description: The text content. - OpenAI.ChatCompletionRequestSystemMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' - description: The contents of the system message. - role: - type: string - enum: - - system - description: The role of the messages author, in this case `system`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestSystemMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestToolMessage: - type: object - required: - - role - - content - - tool_call_id - properties: - role: - type: string - enum: - - tool - description: The role of the messages author, in this case `tool`. - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' - description: The contents of the tool message. - tool_call_id: - type: string - description: Tool call that this message is responding to. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestToolMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestUserMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' - description: The contents of the user message. - x-oaiExpandable: true - role: - type: string - enum: - - user - description: The role of the messages author, in this case `user`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestUserMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' - x-oaiExpandable: true - OpenAI.ChatCompletionResponseMessage: - type: object - required: - - content - - refusal - - role - properties: - content: - type: string - nullable: true - description: The contents of the message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - role: - type: string - enum: - - assistant - description: The role of the author of this message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamOptions: - type: object - properties: - include_usage: - type: boolean - description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' - description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - content: - type: string - nullable: true - description: The contents of the chunk message. + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: type: object properties: @@ -1848,564 +2232,418 @@ components: type: string arguments: type: string + required: + - name + - arguments + nullable: true description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. - OpenAI.ChatCompletionTokenLogprob: - type: object - required: - - token - - logprob - - bytes - - top_logprobs - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - top_logprobs: - type: array - items: - type: object - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: array - items: - type: integer - format: int32 - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - required: - - token - - logprob - - bytes - description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. - OpenAI.ChatCompletionTool: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestAssistantMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestFunctionMessage: type: object required: - - type - - function + - role + - content + - name properties: - type: + role: type: string enum: - function - description: The type of the tool. Currently, only `function` is supported. - function: - $ref: '#/components/schemas/OpenAI.FunctionObject' - OpenAI.ChatCompletionToolChoiceOption: - anyOf: - - type: string - enum: - - none - - auto - - required - - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' - description: |- - Controls which (if any) tool is called by the model. - `none` means the model will not call any tool and instead generates a message. - `auto` means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools. - Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - `none` is the default when no tools are present. `auto` is the default if tools are present. - x-oaiExpandable: true - OpenAI.ChatResponseFormat: + description: The role of the messages author, in this case `function`. + content: + type: string + nullable: true + description: The contents of the function message. + name: + type: string + description: The name of the function to call. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + deprecated: true + OpenAI.ChatCompletionRequestMessage: type: object required: - - type + - role properties: - type: + role: type: string + description: The role of the author of this message. discriminator: - propertyName: type + propertyName: role mapping: - text: '#/components/schemas/OpenAI.ChatResponseFormatText' - json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' - json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' - OpenAI.ChatResponseFormatJsonObject: + system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' + assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' + tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' + function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: - type + - image_url properties: type: type: string enum: - - json_object - description: 'The type of response format being defined: `json_object`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatJsonSchema: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: Either a URL of the image or the base64 encoded image data. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + default: auto + required: + - url + OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: - type - - json_schema + - refusal properties: type: type: string enum: - - json_schema - description: 'The type of response format being defined: `json_schema`' - json_schema: - type: object - properties: - description: - type: string - description: A description of what the response format is for, used by the model to determine how to respond in the format. - name: - type: string - description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - schema: - $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). - default: false - required: - - name - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatText: + - refusal + description: The type of the content part. + refusal: + type: string + description: The refusal message generated by the model. + OpenAI.ChatCompletionRequestMessageContentPartText: type: object required: - type + - text properties: type: type: string enum: - text - description: 'The type of response format being defined: `text`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.CompletionUsage: + description: The type of the content part. + text: + type: string + description: The text content. + OpenAI.ChatCompletionRequestSystemMessage: type: object required: - - completion_tokens - - prompt_tokens - - total_tokens + - content + - role properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens generated by the model. - reasoning_tokens: - type: integer - format: int32 - description: Tokens generated by the model for reasoning. - required: - - audio_tokens - - reasoning_tokens - description: Breakdown of tokens used in a completion. - prompt_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens present in the prompt. - cached_tokens: - type: integer - format: int32 - description: Cached tokens present in the prompt. - required: - - audio_tokens - - cached_tokens - description: Breakdown of tokens used in the prompt. - description: Usage statistics for the completion request. - OpenAI.CreateChatCompletionRequest: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + description: The contents of the system message. + role: + type: string + enum: + - system + description: The role of the messages author, in this case `system`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestSystemMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestToolMessage: type: object required: - - messages - - model + - role + - content + - tool_call_id properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - model: + role: + type: string + enum: + - tool + description: The role of the messages author, in this case `tool`. + content: anyOf: - type: string - - type: string - enum: - - o1-preview - - o1-preview-2024-09-12 - - o1-mini - - o1-mini-2024-09-12 - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - - chatgpt-4o-latest - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0301 - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. - x-oaiTypeLabel: string - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - service_tier: + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' + description: The contents of the tool message. + tool_call_id: type: string - enum: - - auto - - default - nullable: true - description: |- - Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. - default: auto - stop: + description: Tool call that this message is responding to. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestToolMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestUserMessage: + type: object + required: + - content + - role + properties: + content: anyOf: - type: string - type: array items: - type: string + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' + description: The contents of the user message. + x-oaiExpandable: true + role: + type: string + enum: + - user + description: The role of the messages author, in this case `user`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestUserMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + x-oaiExpandable: true + OpenAI.ChatCompletionResponseMessage: + type: object + required: + - content + - refusal + - role + properties: + content: + type: string nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean + description: The contents of the message. + refusal: + type: string nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: + description: The refusal message generated by the model. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + role: + type: string + enum: + - assistant + description: The role of the author of this message. + function_call: type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + description: A chat completion message generated by the model. + OpenAI.ChatCompletionStreamOptions: + type: object + properties: + include_usage: type: boolean - default: true - user: + description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' + description: 'Options for streaming response. Only set this when you set `stream: true`.' + OpenAI.ChatCompletionStreamResponseDelta: + type: object + properties: + content: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + nullable: true + description: The contents of the chunk message. function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - x-oaiExpandable: true - functions: + tool_calls: type: array items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - OpenAI.CreateChatCompletionResponse: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + description: A chat completion delta generated by streamed model responses. + OpenAI.ChatCompletionTokenLogprob: type: object required: - - id - - choices - - created - - model - - object + - token + - logprob + - bytes + - top_logprobs properties: - id: + token: type: string - description: A unique identifier for the chat completion. - choices: + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + top_logprobs: type: array items: type: object properties: - finish_reason: + token: type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: array + items: + type: integer + format: int32 nullable: true - description: Log probability information for the choice. + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: + - token + - logprob + - bytes + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + OpenAI.ChatCompletionTool: + type: object + required: + - type + - function + properties: + type: type: string - description: The model used for the chat completion. - service_tier: + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + OpenAI.ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - auto + - required + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' + description: |- + Controls which (if any) tool is called by the model. + `none` means the model will not call any tool and instead generates a message. + `auto` means the model can pick between generating a message or calling one or more tools. + `required` means the model must call one or more tools. + Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + + `none` is the default when no tools are present. `auto` is the default if tools are present. + x-oaiExpandable: true + OpenAI.ChatResponseFormat: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/OpenAI.ChatResponseFormatText' + json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' + json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' + OpenAI.ChatResponseFormatJsonObject: + type: object + required: + - type + properties: + type: type: string enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: + - json_object + description: 'The type of response format being defined: `json_object`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatJsonSchema: + type: object + required: + - type + - json_schema + properties: + type: type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: + enum: + - json_schema + description: 'The type of response format being defined: `json_schema`' + json_schema: + type: object + properties: + description: + type: string + description: A description of what the response format is for, used by the model to determine how to respond in the format. + name: + type: string + description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + default: false + required: + - name + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatText: + type: object + required: + - type + properties: + type: type: string enum: - - chat.completion - description: The object type, which is always `chat.completion`. - usage: - $ref: '#/components/schemas/OpenAI.CompletionUsage' - description: Represents a chat completion response returned by model, based on the provided input. + - text + description: 'The type of response format being defined: `text`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml index 9a0325be9..d8a490f1e 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml @@ -7,27 +7,6 @@ tags: - name: Images - name: Assistants paths: - /chat/completions: - post: - operationId: createChatCompletion - parameters: [] - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' - - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' - tags: - - Chat - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/AzureCreateChatCompletionRequest' /deployments/{deploymentId}/images/generations: post: operationId: ImageGenerations_Create @@ -86,6 +65,32 @@ paths: application/json: schema: $ref: '#/components/schemas/OpenAI.CreateMessageRequest' + /{deployment_id}/chat/completions: + post: + operationId: createChatCompletion + parameters: + - name: deployment_id + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' + tags: + - Chat + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AzureCreateChatCompletionRequest' security: - ApiKeyAuth: [] - OAuth2Auth: @@ -464,6 +469,43 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. + AzureCompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + - completion_tokens_details + - prompt_tokens_details + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + reasoning_tokens: + type: integer + format: int32 + required: + - reasoning_tokens + prompt_tokens_details: + type: object + properties: + cached_tokens: + type: integer + format: int32 + required: + - cached_tokens AzureContentFilterBlocklistIdResult: type: object required: @@ -861,282 +903,874 @@ components: description: Represents a data source configuration that will use an Azure CosmosDB resource. AzureCreateChatCompletionRequest: type: object + required: + - messages properties: - data_sources: - type: array - items: - $ref: '#/components/schemas/AzureChatDataSource' - description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionRequest' - description: |- - The extended request model for chat completions against the Azure OpenAI service. - This adds the ability to provide data sources for the On Your Data feature. - AzureCreateChatCompletionResponse: - type: object - properties: - prompt_filter_results: + messages: type: array items: - type: object - properties: - prompt_index: - type: integer - format: int32 - description: The index of the input prompt that this content filter result corresponds to. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter results associated with the indexed input prompt. - required: - - prompt_index - - content_filter_results - description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionResponse' - description: |- - The extended top-level chat completion response model for the Azure OpenAI service. - This model adds Responsible AI content filter annotations for prompt input. - AzureImage: - type: object - required: - - prompt_filter_results - - content_filter_results - properties: - prompt_filter_results: - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - content_filter_results: - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' - allOf: - - $ref: '#/components/schemas/OpenAI.Image' - AzureOpenAIChatError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: - type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI chat completion request. - AzureOpenAIChatErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIChatError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIDalleError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI image generation request. - AzureOpenAIDalleErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIDalleError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - description: Known service API versions for Azure OpenAI. - AzureSearchChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - azure_search - description: The discriminated type identifier, which is always 'azure_search'. - parameters: + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array items: type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - format: uri - description: The absolute endpoint path for the Azure Search resource to use. - index_name: - type: string - description: The name of the index to use, as specified in the Azure Search resource. - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - description: The authentication mechanism to use with Azure Search. - fields_mapping: - type: object - properties: - title_field: - type: string - description: The name of the index field to use as a title. - url_field: - type: string - description: The name of the index field to use as a URL. - filepath_field: - type: string - description: The name of the index field to use as a filepath. - content_fields: - type: array - items: - type: string - description: The names of index fields that should be treated as content. - content_fields_separator: - type: string - description: The separator pattern that content fields should use. - vector_fields: - type: array - items: - type: string - description: The names of fields that represent vector data. - image_vector_fields: - type: array - items: - type: string - description: The names of fields that represent image vector data. - description: The field mappings to use with the Azure Search resource. - query_type: - type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string enum: - - simple - - semantic - - vector - - vector_simple_hybrid - - vector_semantic_hybrid - description: The query type for the Azure Search resource to use. - semantic_configuration: - type: string - description: Additional semantic configuration for the query. - filter: - type: string - description: A filter to apply to the search. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' - description: |- - The vectorization source to use with Azure Search. - Supported sources for Azure Search include endpoint, deployment name, and integrated. - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Azure Search data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Search resource. - ChatCompletionMessageToolCallsItem: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' - description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + data_sources: + type: array + items: + $ref: '#/components/schemas/AzureChatDataSource' + description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. + description: |- + The extended request model for chat completions against the Azure OpenAI service. + This adds the ability to provide data sources for the On Your Data feature. + AzureCreateChatCompletionResponse: + type: object + required: + - id + - choices + - created + - model + - object + - usage + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + usage: + $ref: '#/components/schemas/AzureCompletionUsage' + prompt_filter_results: + type: array + items: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt that this content filter result corresponds to. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter results associated with the indexed input prompt. + required: + - prompt_index + - content_filter_results + description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. + description: |- + The extended top-level chat completion response model for the Azure OpenAI service. + This model adds Responsible AI content filter annotations for prompt input. + AzureImage: + type: object + required: + - prompt_filter_results + - content_filter_results + properties: + prompt_filter_results: + $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + content_filter_results: + $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + allOf: + - $ref: '#/components/schemas/OpenAI.Image' + AzureOpenAIChatError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI chat completion request. + AzureOpenAIChatErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIChatError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIDalleError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI image generation request. + AzureOpenAIDalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIDalleError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIServiceApiVersion: + type: string + enum: + - 2024-06-01 + - 2024-08-01-preview + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 + - 2024-12-01-preview + description: Known service API versions for Azure OpenAI. + AzureSearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_search + description: The discriminated type identifier, which is always 'azure_search'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + description: The absolute endpoint path for the Azure Search resource to use. + index_name: + type: string + description: The name of the index to use, as specified in the Azure Search resource. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: The authentication mechanism to use with Azure Search. + fields_mapping: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + items: + type: string + description: The names of index fields that should be treated as content. + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + items: + type: string + description: The names of fields that represent vector data. + image_vector_fields: + type: array + items: + type: string + description: The names of fields that represent image vector data. + description: The field mappings to use with the Azure Search resource. + query_type: + type: string + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: + type: string + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionTokenLogprobBytesItem: + type: array + items: + type: integer + format: int32 + CompletionUsageCommonBase: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + description: Usage statistics for the completion request. + CreateChatCompletionRequestCommonBase: + type: object + required: + - messages + properties: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + CreateChatCompletionResponseCommonBase: + type: object + required: + - id + - choices + - created + - model + - object + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -1588,259 +2222,9 @@ components: description: The role of the messages author, in this case `assistant`. name: type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - nullable: true - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestAssistantMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestFunctionMessage: - type: object - required: - - role - - content - - name - properties: - role: - type: string - enum: - - function - description: The role of the messages author, in this case `function`. - content: - type: string - nullable: true - description: The contents of the function message. - name: - type: string - description: The name of the function to call. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - deprecated: true - OpenAI.ChatCompletionRequestMessage: - type: object - required: - - role - properties: - role: - type: string - description: The role of the author of this message. - discriminator: - propertyName: role - mapping: - system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' - user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' - assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' - tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' - function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestMessageContentPartImage: - type: object - required: - - type - - image_url - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - format: uri - description: Either a URL of the image or the base64 encoded image data. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). - default: auto - required: - - url - OpenAI.ChatCompletionRequestMessageContentPartRefusal: - type: object - required: - - type - - refusal - properties: - type: - type: string - enum: - - refusal - description: The type of the content part. - refusal: - type: string - description: The refusal message generated by the model. - OpenAI.ChatCompletionRequestMessageContentPartText: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: The type of the content part. - text: - type: string - description: The text content. - OpenAI.ChatCompletionRequestSystemMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' - description: The contents of the system message. - role: - type: string - enum: - - system - description: The role of the messages author, in this case `system`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestSystemMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestToolMessage: - type: object - required: - - role - - content - - tool_call_id - properties: - role: - type: string - enum: - - tool - description: The role of the messages author, in this case `tool`. - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' - description: The contents of the tool message. - tool_call_id: - type: string - description: Tool call that this message is responding to. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestToolMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestUserMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' - description: The contents of the user message. - x-oaiExpandable: true - role: - type: string - enum: - - user - description: The role of the messages author, in this case `user`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestUserMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' - x-oaiExpandable: true - OpenAI.ChatCompletionResponseMessage: - type: object - required: - - content - - refusal - - role - properties: - content: - type: string - nullable: true - description: The contents of the message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - role: - type: string - enum: - - assistant - description: The role of the author of this message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamOptions: - type: object - properties: - include_usage: - type: boolean - description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' - description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - content: - type: string - nullable: true - description: The contents of the chunk message. + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: type: object properties: @@ -1848,564 +2232,418 @@ components: type: string arguments: type: string + required: + - name + - arguments + nullable: true description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. - OpenAI.ChatCompletionTokenLogprob: - type: object - required: - - token - - logprob - - bytes - - top_logprobs - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - top_logprobs: - type: array - items: - type: object - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: array - items: - type: integer - format: int32 - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - required: - - token - - logprob - - bytes - description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. - OpenAI.ChatCompletionTool: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestAssistantMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestFunctionMessage: type: object required: - - type - - function + - role + - content + - name properties: - type: + role: type: string enum: - function - description: The type of the tool. Currently, only `function` is supported. - function: - $ref: '#/components/schemas/OpenAI.FunctionObject' - OpenAI.ChatCompletionToolChoiceOption: - anyOf: - - type: string - enum: - - none - - auto - - required - - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' - description: |- - Controls which (if any) tool is called by the model. - `none` means the model will not call any tool and instead generates a message. - `auto` means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools. - Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - `none` is the default when no tools are present. `auto` is the default if tools are present. - x-oaiExpandable: true - OpenAI.ChatResponseFormat: + description: The role of the messages author, in this case `function`. + content: + type: string + nullable: true + description: The contents of the function message. + name: + type: string + description: The name of the function to call. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + deprecated: true + OpenAI.ChatCompletionRequestMessage: type: object required: - - type + - role properties: - type: + role: type: string + description: The role of the author of this message. discriminator: - propertyName: type + propertyName: role mapping: - text: '#/components/schemas/OpenAI.ChatResponseFormatText' - json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' - json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' - OpenAI.ChatResponseFormatJsonObject: + system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' + assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' + tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' + function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: - type + - image_url properties: type: type: string enum: - - json_object - description: 'The type of response format being defined: `json_object`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatJsonSchema: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: Either a URL of the image or the base64 encoded image data. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + default: auto + required: + - url + OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: - type - - json_schema + - refusal properties: type: type: string enum: - - json_schema - description: 'The type of response format being defined: `json_schema`' - json_schema: - type: object - properties: - description: - type: string - description: A description of what the response format is for, used by the model to determine how to respond in the format. - name: - type: string - description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - schema: - $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). - default: false - required: - - name - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatText: + - refusal + description: The type of the content part. + refusal: + type: string + description: The refusal message generated by the model. + OpenAI.ChatCompletionRequestMessageContentPartText: type: object required: - type + - text properties: type: type: string enum: - text - description: 'The type of response format being defined: `text`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.CompletionUsage: + description: The type of the content part. + text: + type: string + description: The text content. + OpenAI.ChatCompletionRequestSystemMessage: type: object required: - - completion_tokens - - prompt_tokens - - total_tokens + - content + - role properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens generated by the model. - reasoning_tokens: - type: integer - format: int32 - description: Tokens generated by the model for reasoning. - required: - - audio_tokens - - reasoning_tokens - description: Breakdown of tokens used in a completion. - prompt_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens present in the prompt. - cached_tokens: - type: integer - format: int32 - description: Cached tokens present in the prompt. - required: - - audio_tokens - - cached_tokens - description: Breakdown of tokens used in the prompt. - description: Usage statistics for the completion request. - OpenAI.CreateChatCompletionRequest: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + description: The contents of the system message. + role: + type: string + enum: + - system + description: The role of the messages author, in this case `system`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestSystemMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestToolMessage: type: object required: - - messages - - model + - role + - content + - tool_call_id properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - model: + role: + type: string + enum: + - tool + description: The role of the messages author, in this case `tool`. + content: anyOf: - type: string - - type: string - enum: - - o1-preview - - o1-preview-2024-09-12 - - o1-mini - - o1-mini-2024-09-12 - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - - chatgpt-4o-latest - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0301 - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. - x-oaiTypeLabel: string - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - service_tier: + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' + description: The contents of the tool message. + tool_call_id: type: string - enum: - - auto - - default - nullable: true - description: |- - Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. - default: auto - stop: + description: Tool call that this message is responding to. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestToolMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestUserMessage: + type: object + required: + - content + - role + properties: + content: anyOf: - type: string - type: array items: - type: string + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' + description: The contents of the user message. + x-oaiExpandable: true + role: + type: string + enum: + - user + description: The role of the messages author, in this case `user`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestUserMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + x-oaiExpandable: true + OpenAI.ChatCompletionResponseMessage: + type: object + required: + - content + - refusal + - role + properties: + content: + type: string nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean + description: The contents of the message. + refusal: + type: string nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: + description: The refusal message generated by the model. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + role: + type: string + enum: + - assistant + description: The role of the author of this message. + function_call: type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + description: A chat completion message generated by the model. + OpenAI.ChatCompletionStreamOptions: + type: object + properties: + include_usage: type: boolean - default: true - user: + description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' + description: 'Options for streaming response. Only set this when you set `stream: true`.' + OpenAI.ChatCompletionStreamResponseDelta: + type: object + properties: + content: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + nullable: true + description: The contents of the chunk message. function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - x-oaiExpandable: true - functions: + tool_calls: type: array items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - OpenAI.CreateChatCompletionResponse: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + description: A chat completion delta generated by streamed model responses. + OpenAI.ChatCompletionTokenLogprob: type: object required: - - id - - choices - - created - - model - - object + - token + - logprob + - bytes + - top_logprobs properties: - id: + token: type: string - description: A unique identifier for the chat completion. - choices: + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + top_logprobs: type: array items: type: object properties: - finish_reason: + token: type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: array + items: + type: integer + format: int32 nullable: true - description: Log probability information for the choice. + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: + - token + - logprob + - bytes + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + OpenAI.ChatCompletionTool: + type: object + required: + - type + - function + properties: + type: type: string - description: The model used for the chat completion. - service_tier: + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + OpenAI.ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - auto + - required + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' + description: |- + Controls which (if any) tool is called by the model. + `none` means the model will not call any tool and instead generates a message. + `auto` means the model can pick between generating a message or calling one or more tools. + `required` means the model must call one or more tools. + Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + + `none` is the default when no tools are present. `auto` is the default if tools are present. + x-oaiExpandable: true + OpenAI.ChatResponseFormat: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/OpenAI.ChatResponseFormatText' + json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' + json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' + OpenAI.ChatResponseFormatJsonObject: + type: object + required: + - type + properties: + type: type: string enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: + - json_object + description: 'The type of response format being defined: `json_object`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatJsonSchema: + type: object + required: + - type + - json_schema + properties: + type: type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: + enum: + - json_schema + description: 'The type of response format being defined: `json_schema`' + json_schema: + type: object + properties: + description: + type: string + description: A description of what the response format is for, used by the model to determine how to respond in the format. + name: + type: string + description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + default: false + required: + - name + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatText: + type: object + required: + - type + properties: + type: type: string enum: - - chat.completion - description: The object type, which is always `chat.completion`. - usage: - $ref: '#/components/schemas/OpenAI.CompletionUsage' - description: Represents a chat completion response returned by model, based on the provided input. + - text + description: 'The type of response format being defined: `text`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml index e99981b86..2463b9fdc 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml @@ -7,27 +7,6 @@ tags: - name: Images - name: Assistants paths: - /chat/completions: - post: - operationId: createChatCompletion - parameters: [] - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' - - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' - tags: - - Chat - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/AzureCreateChatCompletionRequest' /deployments/{deploymentId}/images/generations: post: operationId: ImageGenerations_Create @@ -86,6 +65,32 @@ paths: application/json: schema: $ref: '#/components/schemas/OpenAI.CreateMessageRequest' + /{deployment_id}/chat/completions: + post: + operationId: createChatCompletion + parameters: + - name: deployment_id + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' + tags: + - Chat + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AzureCreateChatCompletionRequest' security: - ApiKeyAuth: [] - OAuth2Auth: @@ -464,6 +469,43 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. + AzureCompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + - completion_tokens_details + - prompt_tokens_details + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + reasoning_tokens: + type: integer + format: int32 + required: + - reasoning_tokens + prompt_tokens_details: + type: object + properties: + cached_tokens: + type: integer + format: int32 + required: + - cached_tokens AzureContentFilterBlocklistIdResult: type: object required: @@ -896,282 +938,874 @@ components: description: Represents a data source configuration that will use an Azure CosmosDB resource. AzureCreateChatCompletionRequest: type: object + required: + - messages properties: - data_sources: - type: array - items: - $ref: '#/components/schemas/AzureChatDataSource' - description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionRequest' - description: |- - The extended request model for chat completions against the Azure OpenAI service. - This adds the ability to provide data sources for the On Your Data feature. - AzureCreateChatCompletionResponse: - type: object - properties: - prompt_filter_results: + messages: type: array items: - type: object - properties: - prompt_index: - type: integer - format: int32 - description: The index of the input prompt that this content filter result corresponds to. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter results associated with the indexed input prompt. - required: - - prompt_index - - content_filter_results - description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionResponse' - description: |- - The extended top-level chat completion response model for the Azure OpenAI service. - This model adds Responsible AI content filter annotations for prompt input. - AzureImage: - type: object - required: - - prompt_filter_results - - content_filter_results - properties: - prompt_filter_results: - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - content_filter_results: - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' - allOf: - - $ref: '#/components/schemas/OpenAI.Image' - AzureOpenAIChatError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: - type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI chat completion request. - AzureOpenAIChatErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIChatError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIDalleError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI image generation request. - AzureOpenAIDalleErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIDalleError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - description: Known service API versions for Azure OpenAI. - AzureSearchChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - azure_search - description: The discriminated type identifier, which is always 'azure_search'. - parameters: + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array items: type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - format: uri - description: The absolute endpoint path for the Azure Search resource to use. - index_name: - type: string - description: The name of the index to use, as specified in the Azure Search resource. - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - description: The authentication mechanism to use with Azure Search. - fields_mapping: - type: object - properties: - title_field: - type: string - description: The name of the index field to use as a title. - url_field: - type: string - description: The name of the index field to use as a URL. - filepath_field: - type: string - description: The name of the index field to use as a filepath. - content_fields: - type: array - items: - type: string - description: The names of index fields that should be treated as content. - content_fields_separator: - type: string - description: The separator pattern that content fields should use. - vector_fields: - type: array - items: - type: string - description: The names of fields that represent vector data. - image_vector_fields: - type: array - items: - type: string - description: The names of fields that represent image vector data. - description: The field mappings to use with the Azure Search resource. - query_type: - type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string enum: - - simple - - semantic - - vector - - vector_simple_hybrid - - vector_semantic_hybrid - description: The query type for the Azure Search resource to use. - semantic_configuration: - type: string - description: Additional semantic configuration for the query. - filter: - type: string - description: A filter to apply to the search. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' - description: |- - The vectorization source to use with Azure Search. - Supported sources for Azure Search include endpoint, deployment name, and integrated. - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Azure Search data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Search resource. - ChatCompletionMessageToolCallsItem: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' - description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + data_sources: + type: array + items: + $ref: '#/components/schemas/AzureChatDataSource' + description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. + description: |- + The extended request model for chat completions against the Azure OpenAI service. + This adds the ability to provide data sources for the On Your Data feature. + AzureCreateChatCompletionResponse: + type: object + required: + - id + - choices + - created + - model + - object + - usage + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + usage: + $ref: '#/components/schemas/AzureCompletionUsage' + prompt_filter_results: + type: array + items: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt that this content filter result corresponds to. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter results associated with the indexed input prompt. + required: + - prompt_index + - content_filter_results + description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. + description: |- + The extended top-level chat completion response model for the Azure OpenAI service. + This model adds Responsible AI content filter annotations for prompt input. + AzureImage: + type: object + required: + - prompt_filter_results + - content_filter_results + properties: + prompt_filter_results: + $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + content_filter_results: + $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + allOf: + - $ref: '#/components/schemas/OpenAI.Image' + AzureOpenAIChatError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI chat completion request. + AzureOpenAIChatErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIChatError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIDalleError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI image generation request. + AzureOpenAIDalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIDalleError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIServiceApiVersion: + type: string + enum: + - 2024-06-01 + - 2024-08-01-preview + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 + - 2024-12-01-preview + description: Known service API versions for Azure OpenAI. + AzureSearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_search + description: The discriminated type identifier, which is always 'azure_search'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + description: The absolute endpoint path for the Azure Search resource to use. + index_name: + type: string + description: The name of the index to use, as specified in the Azure Search resource. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: The authentication mechanism to use with Azure Search. + fields_mapping: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + items: + type: string + description: The names of index fields that should be treated as content. + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + items: + type: string + description: The names of fields that represent vector data. + image_vector_fields: + type: array + items: + type: string + description: The names of fields that represent image vector data. + description: The field mappings to use with the Azure Search resource. + query_type: + type: string + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: + type: string + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionTokenLogprobBytesItem: + type: array + items: + type: integer + format: int32 + CompletionUsageCommonBase: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + description: Usage statistics for the completion request. + CreateChatCompletionRequestCommonBase: + type: object + required: + - messages + properties: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + CreateChatCompletionResponseCommonBase: + type: object + required: + - id + - choices + - created + - model + - object + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -1623,259 +2257,9 @@ components: description: The role of the messages author, in this case `assistant`. name: type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - nullable: true - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestAssistantMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestFunctionMessage: - type: object - required: - - role - - content - - name - properties: - role: - type: string - enum: - - function - description: The role of the messages author, in this case `function`. - content: - type: string - nullable: true - description: The contents of the function message. - name: - type: string - description: The name of the function to call. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - deprecated: true - OpenAI.ChatCompletionRequestMessage: - type: object - required: - - role - properties: - role: - type: string - description: The role of the author of this message. - discriminator: - propertyName: role - mapping: - system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' - user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' - assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' - tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' - function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestMessageContentPartImage: - type: object - required: - - type - - image_url - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - format: uri - description: Either a URL of the image or the base64 encoded image data. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). - default: auto - required: - - url - OpenAI.ChatCompletionRequestMessageContentPartRefusal: - type: object - required: - - type - - refusal - properties: - type: - type: string - enum: - - refusal - description: The type of the content part. - refusal: - type: string - description: The refusal message generated by the model. - OpenAI.ChatCompletionRequestMessageContentPartText: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: The type of the content part. - text: - type: string - description: The text content. - OpenAI.ChatCompletionRequestSystemMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' - description: The contents of the system message. - role: - type: string - enum: - - system - description: The role of the messages author, in this case `system`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestSystemMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestToolMessage: - type: object - required: - - role - - content - - tool_call_id - properties: - role: - type: string - enum: - - tool - description: The role of the messages author, in this case `tool`. - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' - description: The contents of the tool message. - tool_call_id: - type: string - description: Tool call that this message is responding to. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestToolMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestUserMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' - description: The contents of the user message. - x-oaiExpandable: true - role: - type: string - enum: - - user - description: The role of the messages author, in this case `user`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestUserMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' - x-oaiExpandable: true - OpenAI.ChatCompletionResponseMessage: - type: object - required: - - content - - refusal - - role - properties: - content: - type: string - nullable: true - description: The contents of the message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - role: - type: string - enum: - - assistant - description: The role of the author of this message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamOptions: - type: object - properties: - include_usage: - type: boolean - description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' - description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - content: - type: string - nullable: true - description: The contents of the chunk message. + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: type: object properties: @@ -1883,564 +2267,418 @@ components: type: string arguments: type: string + required: + - name + - arguments + nullable: true description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. - OpenAI.ChatCompletionTokenLogprob: - type: object - required: - - token - - logprob - - bytes - - top_logprobs - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - top_logprobs: - type: array - items: - type: object - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: array - items: - type: integer - format: int32 - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - required: - - token - - logprob - - bytes - description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. - OpenAI.ChatCompletionTool: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestAssistantMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestFunctionMessage: type: object required: - - type - - function + - role + - content + - name properties: - type: + role: type: string enum: - function - description: The type of the tool. Currently, only `function` is supported. - function: - $ref: '#/components/schemas/OpenAI.FunctionObject' - OpenAI.ChatCompletionToolChoiceOption: - anyOf: - - type: string - enum: - - none - - auto - - required - - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' - description: |- - Controls which (if any) tool is called by the model. - `none` means the model will not call any tool and instead generates a message. - `auto` means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools. - Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - `none` is the default when no tools are present. `auto` is the default if tools are present. - x-oaiExpandable: true - OpenAI.ChatResponseFormat: + description: The role of the messages author, in this case `function`. + content: + type: string + nullable: true + description: The contents of the function message. + name: + type: string + description: The name of the function to call. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + deprecated: true + OpenAI.ChatCompletionRequestMessage: type: object required: - - type + - role properties: - type: + role: type: string + description: The role of the author of this message. discriminator: - propertyName: type + propertyName: role mapping: - text: '#/components/schemas/OpenAI.ChatResponseFormatText' - json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' - json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' - OpenAI.ChatResponseFormatJsonObject: + system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' + assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' + tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' + function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: - type + - image_url properties: type: type: string enum: - - json_object - description: 'The type of response format being defined: `json_object`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatJsonSchema: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: Either a URL of the image or the base64 encoded image data. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + default: auto + required: + - url + OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: - type - - json_schema + - refusal properties: type: type: string enum: - - json_schema - description: 'The type of response format being defined: `json_schema`' - json_schema: - type: object - properties: - description: - type: string - description: A description of what the response format is for, used by the model to determine how to respond in the format. - name: - type: string - description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - schema: - $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). - default: false - required: - - name - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatText: + - refusal + description: The type of the content part. + refusal: + type: string + description: The refusal message generated by the model. + OpenAI.ChatCompletionRequestMessageContentPartText: type: object required: - type + - text properties: type: type: string enum: - text - description: 'The type of response format being defined: `text`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.CompletionUsage: + description: The type of the content part. + text: + type: string + description: The text content. + OpenAI.ChatCompletionRequestSystemMessage: type: object required: - - completion_tokens - - prompt_tokens - - total_tokens + - content + - role properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens generated by the model. - reasoning_tokens: - type: integer - format: int32 - description: Tokens generated by the model for reasoning. - required: - - audio_tokens - - reasoning_tokens - description: Breakdown of tokens used in a completion. - prompt_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens present in the prompt. - cached_tokens: - type: integer - format: int32 - description: Cached tokens present in the prompt. - required: - - audio_tokens - - cached_tokens - description: Breakdown of tokens used in the prompt. - description: Usage statistics for the completion request. - OpenAI.CreateChatCompletionRequest: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + description: The contents of the system message. + role: + type: string + enum: + - system + description: The role of the messages author, in this case `system`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestSystemMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestToolMessage: type: object required: - - messages - - model + - role + - content + - tool_call_id properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - model: + role: + type: string + enum: + - tool + description: The role of the messages author, in this case `tool`. + content: anyOf: - type: string - - type: string - enum: - - o1-preview - - o1-preview-2024-09-12 - - o1-mini - - o1-mini-2024-09-12 - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - - chatgpt-4o-latest - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0301 - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. - x-oaiTypeLabel: string - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - service_tier: + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' + description: The contents of the tool message. + tool_call_id: type: string - enum: - - auto - - default - nullable: true - description: |- - Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. - default: auto - stop: + description: Tool call that this message is responding to. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestToolMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestUserMessage: + type: object + required: + - content + - role + properties: + content: anyOf: - type: string - type: array items: - type: string + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' + description: The contents of the user message. + x-oaiExpandable: true + role: + type: string + enum: + - user + description: The role of the messages author, in this case `user`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestUserMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + x-oaiExpandable: true + OpenAI.ChatCompletionResponseMessage: + type: object + required: + - content + - refusal + - role + properties: + content: + type: string nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean + description: The contents of the message. + refusal: + type: string nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: + description: The refusal message generated by the model. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + role: + type: string + enum: + - assistant + description: The role of the author of this message. + function_call: type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + description: A chat completion message generated by the model. + OpenAI.ChatCompletionStreamOptions: + type: object + properties: + include_usage: type: boolean - default: true - user: + description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' + description: 'Options for streaming response. Only set this when you set `stream: true`.' + OpenAI.ChatCompletionStreamResponseDelta: + type: object + properties: + content: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + nullable: true + description: The contents of the chunk message. function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - x-oaiExpandable: true - functions: + tool_calls: type: array items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - OpenAI.CreateChatCompletionResponse: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + description: A chat completion delta generated by streamed model responses. + OpenAI.ChatCompletionTokenLogprob: type: object required: - - id - - choices - - created - - model - - object + - token + - logprob + - bytes + - top_logprobs properties: - id: + token: type: string - description: A unique identifier for the chat completion. - choices: + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + top_logprobs: type: array items: type: object properties: - finish_reason: + token: type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: array + items: + type: integer + format: int32 nullable: true - description: Log probability information for the choice. + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: + - token + - logprob + - bytes + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + OpenAI.ChatCompletionTool: + type: object + required: + - type + - function + properties: + type: type: string - description: The model used for the chat completion. - service_tier: + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + OpenAI.ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - auto + - required + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' + description: |- + Controls which (if any) tool is called by the model. + `none` means the model will not call any tool and instead generates a message. + `auto` means the model can pick between generating a message or calling one or more tools. + `required` means the model must call one or more tools. + Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + + `none` is the default when no tools are present. `auto` is the default if tools are present. + x-oaiExpandable: true + OpenAI.ChatResponseFormat: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/OpenAI.ChatResponseFormatText' + json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' + json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' + OpenAI.ChatResponseFormatJsonObject: + type: object + required: + - type + properties: + type: type: string enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: + - json_object + description: 'The type of response format being defined: `json_object`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatJsonSchema: + type: object + required: + - type + - json_schema + properties: + type: type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: + enum: + - json_schema + description: 'The type of response format being defined: `json_schema`' + json_schema: + type: object + properties: + description: + type: string + description: A description of what the response format is for, used by the model to determine how to respond in the format. + name: + type: string + description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + default: false + required: + - name + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatText: + type: object + required: + - type + properties: + type: type: string enum: - - chat.completion - description: The object type, which is always `chat.completion`. - usage: - $ref: '#/components/schemas/OpenAI.CompletionUsage' - description: Represents a chat completion response returned by model, based on the provided input. + - text + description: 'The type of response format being defined: `text`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml index 55f5b98bf..463e02875 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml @@ -7,27 +7,6 @@ tags: - name: Images - name: Assistants paths: - /chat/completions: - post: - operationId: createChatCompletion - parameters: [] - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' - - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' - tags: - - Chat - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/AzureCreateChatCompletionRequest' /deployments/{deploymentId}/images/generations: post: operationId: ImageGenerations_Create @@ -86,6 +65,32 @@ paths: application/json: schema: $ref: '#/components/schemas/OpenAI.CreateMessageRequest' + /{deployment_id}/chat/completions: + post: + operationId: createChatCompletion + parameters: + - name: deployment_id + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' + tags: + - Chat + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AzureCreateChatCompletionRequest' security: - ApiKeyAuth: [] - OAuth2Auth: @@ -464,6 +469,43 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. + AzureCompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + - completion_tokens_details + - prompt_tokens_details + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + reasoning_tokens: + type: integer + format: int32 + required: + - reasoning_tokens + prompt_tokens_details: + type: object + properties: + cached_tokens: + type: integer + format: int32 + required: + - cached_tokens AzureContentFilterBlocklistIdResult: type: object required: @@ -876,338 +918,930 @@ components: description: Represents a data source configuration that will use an Azure CosmosDB resource. AzureCreateChatCompletionRequest: type: object + required: + - messages properties: - data_sources: - type: array - items: - $ref: '#/components/schemas/AzureChatDataSource' - description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionRequest' - description: |- - The extended request model for chat completions against the Azure OpenAI service. - This adds the ability to provide data sources for the On Your Data feature. - AzureCreateChatCompletionResponse: - type: object - properties: - prompt_filter_results: + messages: type: array items: - type: object - properties: - prompt_index: - type: integer - format: int32 - description: The index of the input prompt that this content filter result corresponds to. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter results associated with the indexed input prompt. - required: - - prompt_index - - content_filter_results - description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionResponse' - description: |- - The extended top-level chat completion response model for the Azure OpenAI service. - This model adds Responsible AI content filter annotations for prompt input. - AzureImage: - type: object - required: - - prompt_filter_results - - content_filter_results - properties: - prompt_filter_results: - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - content_filter_results: - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' - allOf: - - $ref: '#/components/schemas/OpenAI.Image' - AzureOpenAIChatError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI chat completion request. - AzureOpenAIChatErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIChatError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIDalleError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI image generation request. - AzureOpenAIDalleErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIDalleError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIFile: - type: object - required: - - id - - bytes - - created_at - - filename - - object - - purpose - - status - properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 + additionalProperties: + type: integer + format: int32 nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - enum: - - file - description: The object type, which is always `file`. - purpose: - type: string - enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - status_details: - type: string - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true - status: + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: type: string - enum: - - uploaded - - pending - - running - - processed - - error - - deleting - - deleted - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - description: Known service API versions for Azure OpenAI. - AzureSearchChatDataSource: + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + data_sources: + type: array + items: + $ref: '#/components/schemas/AzureChatDataSource' + description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. + description: |- + The extended request model for chat completions against the Azure OpenAI service. + This adds the ability to provide data sources for the On Your Data feature. + AzureCreateChatCompletionResponse: type: object required: - - type - - parameters + - id + - choices + - created + - model + - object + - usage properties: - type: + id: type: string - enum: - - azure_search - description: The discriminated type identifier, which is always 'azure_search'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: type: string enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + usage: + $ref: '#/components/schemas/AzureCompletionUsage' + prompt_filter_results: + type: array + items: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt that this content filter result corresponds to. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter results associated with the indexed input prompt. + required: + - prompt_index + - content_filter_results + description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. + description: |- + The extended top-level chat completion response model for the Azure OpenAI service. + This model adds Responsible AI content filter annotations for prompt input. + AzureImage: + type: object + required: + - prompt_filter_results + - content_filter_results + properties: + prompt_filter_results: + $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + content_filter_results: + $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + allOf: + - $ref: '#/components/schemas/OpenAI.Image' + AzureOpenAIChatError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: type: string - format: uri - description: The absolute endpoint path for the Azure Search resource to use. - index_name: + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: type: string - description: The name of the index to use, as specified in the Azure Search resource. - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - description: The authentication mechanism to use with Azure Search. - fields_mapping: - type: object - properties: - title_field: - type: string - description: The name of the index field to use as a title. - url_field: - type: string - description: The name of the index field to use as a URL. - filepath_field: - type: string - description: The name of the index field to use as a filepath. - content_fields: - type: array - items: - type: string - description: The names of index fields that should be treated as content. - content_fields_separator: - type: string - description: The separator pattern that content fields should use. - vector_fields: - type: array - items: - type: string - description: The names of fields that represent vector data. - image_vector_fields: - type: array - items: - type: string - description: The names of fields that represent image vector data. - description: The field mappings to use with the Azure Search resource. - query_type: + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI chat completion request. + AzureOpenAIChatErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIChatError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIDalleError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: type: string enum: - - simple - - semantic - - vector - - vector_simple_hybrid - - vector_semantic_hybrid - description: The query type for the Azure Search resource to use. - semantic_configuration: - type: string - description: Additional semantic configuration for the query. - filter: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: type: string - description: A filter to apply to the search. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' - description: |- - The vectorization source to use with Azure Search. - Supported sources for Azure Search include endpoint, deployment name, and integrated. - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Azure Search data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Search resource. - ChatCompletionMessageToolCallsItem: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' - description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI image generation request. + AzureOpenAIDalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIDalleError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIFile: + type: object + required: + - id + - bytes + - created_at + - filename + - object + - purpose + - status + properties: + id: + type: string + description: The file identifier, which can be referenced in the API endpoints. + bytes: + type: integer + format: int32 + nullable: true + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + filename: + type: string + description: The name of the file. + object: + type: string + enum: + - file + description: The object type, which is always `file`. + purpose: + type: string + enum: + - assistants + - assistants_output + - batch + - batch_output + - fine-tune + - fine-tune-results + - vision + description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. + status_details: + type: string + description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + deprecated: true + status: + type: string + enum: + - uploaded + - pending + - running + - processed + - error + - deleting + - deleted + AzureOpenAIServiceApiVersion: + type: string + enum: + - 2024-06-01 + - 2024-08-01-preview + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 + - 2024-12-01-preview + description: Known service API versions for Azure OpenAI. + AzureSearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_search + description: The discriminated type identifier, which is always 'azure_search'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + description: The absolute endpoint path for the Azure Search resource to use. + index_name: + type: string + description: The name of the index to use, as specified in the Azure Search resource. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: The authentication mechanism to use with Azure Search. + fields_mapping: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + items: + type: string + description: The names of index fields that should be treated as content. + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + items: + type: string + description: The names of fields that represent vector data. + image_vector_fields: + type: array + items: + type: string + description: The names of fields that represent image vector data. + description: The field mappings to use with the Azure Search resource. + query_type: + type: string + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: + type: string + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionTokenLogprobBytesItem: + type: array + items: + type: integer + format: int32 + CompletionUsageCommonBase: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + description: Usage statistics for the completion request. + CreateChatCompletionRequestCommonBase: + type: object + required: + - messages + properties: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + CreateChatCompletionResponseCommonBase: + type: object + required: + - id + - choices + - created + - model + - object + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -1659,259 +2293,9 @@ components: description: The role of the messages author, in this case `assistant`. name: type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - nullable: true - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestAssistantMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestFunctionMessage: - type: object - required: - - role - - content - - name - properties: - role: - type: string - enum: - - function - description: The role of the messages author, in this case `function`. - content: - type: string - nullable: true - description: The contents of the function message. - name: - type: string - description: The name of the function to call. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - deprecated: true - OpenAI.ChatCompletionRequestMessage: - type: object - required: - - role - properties: - role: - type: string - description: The role of the author of this message. - discriminator: - propertyName: role - mapping: - system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' - user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' - assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' - tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' - function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestMessageContentPartImage: - type: object - required: - - type - - image_url - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - format: uri - description: Either a URL of the image or the base64 encoded image data. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). - default: auto - required: - - url - OpenAI.ChatCompletionRequestMessageContentPartRefusal: - type: object - required: - - type - - refusal - properties: - type: - type: string - enum: - - refusal - description: The type of the content part. - refusal: - type: string - description: The refusal message generated by the model. - OpenAI.ChatCompletionRequestMessageContentPartText: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: The type of the content part. - text: - type: string - description: The text content. - OpenAI.ChatCompletionRequestSystemMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' - description: The contents of the system message. - role: - type: string - enum: - - system - description: The role of the messages author, in this case `system`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestSystemMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestToolMessage: - type: object - required: - - role - - content - - tool_call_id - properties: - role: - type: string - enum: - - tool - description: The role of the messages author, in this case `tool`. - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' - description: The contents of the tool message. - tool_call_id: - type: string - description: Tool call that this message is responding to. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestToolMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestUserMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' - description: The contents of the user message. - x-oaiExpandable: true - role: - type: string - enum: - - user - description: The role of the messages author, in this case `user`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestUserMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' - x-oaiExpandable: true - OpenAI.ChatCompletionResponseMessage: - type: object - required: - - content - - refusal - - role - properties: - content: - type: string - nullable: true - description: The contents of the message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - role: - type: string - enum: - - assistant - description: The role of the author of this message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamOptions: - type: object - properties: - include_usage: - type: boolean - description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' - description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - content: - type: string - nullable: true - description: The contents of the chunk message. + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: type: object properties: @@ -1919,564 +2303,418 @@ components: type: string arguments: type: string + required: + - name + - arguments + nullable: true description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. - OpenAI.ChatCompletionTokenLogprob: - type: object - required: - - token - - logprob - - bytes - - top_logprobs - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - top_logprobs: - type: array - items: - type: object - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: array - items: - type: integer - format: int32 - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - required: - - token - - logprob - - bytes - description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. - OpenAI.ChatCompletionTool: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestAssistantMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestFunctionMessage: type: object required: - - type - - function + - role + - content + - name properties: - type: + role: type: string enum: - function - description: The type of the tool. Currently, only `function` is supported. - function: - $ref: '#/components/schemas/OpenAI.FunctionObject' - OpenAI.ChatCompletionToolChoiceOption: - anyOf: - - type: string - enum: - - none - - auto - - required - - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' - description: |- - Controls which (if any) tool is called by the model. - `none` means the model will not call any tool and instead generates a message. - `auto` means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools. - Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - `none` is the default when no tools are present. `auto` is the default if tools are present. - x-oaiExpandable: true - OpenAI.ChatResponseFormat: + description: The role of the messages author, in this case `function`. + content: + type: string + nullable: true + description: The contents of the function message. + name: + type: string + description: The name of the function to call. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + deprecated: true + OpenAI.ChatCompletionRequestMessage: type: object required: - - type + - role properties: - type: + role: type: string + description: The role of the author of this message. discriminator: - propertyName: type + propertyName: role mapping: - text: '#/components/schemas/OpenAI.ChatResponseFormatText' - json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' - json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' - OpenAI.ChatResponseFormatJsonObject: + system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' + assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' + tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' + function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: - type + - image_url properties: type: type: string enum: - - json_object - description: 'The type of response format being defined: `json_object`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatJsonSchema: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: Either a URL of the image or the base64 encoded image data. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + default: auto + required: + - url + OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: - type - - json_schema + - refusal properties: type: type: string enum: - - json_schema - description: 'The type of response format being defined: `json_schema`' - json_schema: - type: object - properties: - description: - type: string - description: A description of what the response format is for, used by the model to determine how to respond in the format. - name: - type: string - description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - schema: - $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). - default: false - required: - - name - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatText: + - refusal + description: The type of the content part. + refusal: + type: string + description: The refusal message generated by the model. + OpenAI.ChatCompletionRequestMessageContentPartText: type: object required: - type + - text properties: type: type: string enum: - text - description: 'The type of response format being defined: `text`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.CompletionUsage: + description: The type of the content part. + text: + type: string + description: The text content. + OpenAI.ChatCompletionRequestSystemMessage: type: object required: - - completion_tokens - - prompt_tokens - - total_tokens + - content + - role properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens generated by the model. - reasoning_tokens: - type: integer - format: int32 - description: Tokens generated by the model for reasoning. - required: - - audio_tokens - - reasoning_tokens - description: Breakdown of tokens used in a completion. - prompt_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens present in the prompt. - cached_tokens: - type: integer - format: int32 - description: Cached tokens present in the prompt. - required: - - audio_tokens - - cached_tokens - description: Breakdown of tokens used in the prompt. - description: Usage statistics for the completion request. - OpenAI.CreateChatCompletionRequest: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + description: The contents of the system message. + role: + type: string + enum: + - system + description: The role of the messages author, in this case `system`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestSystemMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestToolMessage: type: object required: - - messages - - model + - role + - content + - tool_call_id properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - model: + role: + type: string + enum: + - tool + description: The role of the messages author, in this case `tool`. + content: anyOf: - type: string - - type: string - enum: - - o1-preview - - o1-preview-2024-09-12 - - o1-mini - - o1-mini-2024-09-12 - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - - chatgpt-4o-latest - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0301 - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. - x-oaiTypeLabel: string - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - service_tier: + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' + description: The contents of the tool message. + tool_call_id: type: string - enum: - - auto - - default - nullable: true - description: |- - Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. - default: auto - stop: + description: Tool call that this message is responding to. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestToolMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestUserMessage: + type: object + required: + - content + - role + properties: + content: anyOf: - type: string - type: array items: - type: string + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' + description: The contents of the user message. + x-oaiExpandable: true + role: + type: string + enum: + - user + description: The role of the messages author, in this case `user`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestUserMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + x-oaiExpandable: true + OpenAI.ChatCompletionResponseMessage: + type: object + required: + - content + - refusal + - role + properties: + content: + type: string nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean + description: The contents of the message. + refusal: + type: string nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: + description: The refusal message generated by the model. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + role: + type: string + enum: + - assistant + description: The role of the author of this message. + function_call: type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + description: A chat completion message generated by the model. + OpenAI.ChatCompletionStreamOptions: + type: object + properties: + include_usage: type: boolean - default: true - user: + description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' + description: 'Options for streaming response. Only set this when you set `stream: true`.' + OpenAI.ChatCompletionStreamResponseDelta: + type: object + properties: + content: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + nullable: true + description: The contents of the chunk message. function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - x-oaiExpandable: true - functions: + tool_calls: type: array items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - OpenAI.CreateChatCompletionResponse: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + description: A chat completion delta generated by streamed model responses. + OpenAI.ChatCompletionTokenLogprob: type: object required: - - id - - choices - - created - - model - - object + - token + - logprob + - bytes + - top_logprobs properties: - id: + token: type: string - description: A unique identifier for the chat completion. - choices: + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + top_logprobs: type: array items: type: object properties: - finish_reason: + token: type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: array + items: + type: integer + format: int32 nullable: true - description: Log probability information for the choice. + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: + - token + - logprob + - bytes + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + OpenAI.ChatCompletionTool: + type: object + required: + - type + - function + properties: + type: type: string - description: The model used for the chat completion. - service_tier: + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + OpenAI.ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - auto + - required + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' + description: |- + Controls which (if any) tool is called by the model. + `none` means the model will not call any tool and instead generates a message. + `auto` means the model can pick between generating a message or calling one or more tools. + `required` means the model must call one or more tools. + Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + + `none` is the default when no tools are present. `auto` is the default if tools are present. + x-oaiExpandable: true + OpenAI.ChatResponseFormat: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/OpenAI.ChatResponseFormatText' + json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' + json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' + OpenAI.ChatResponseFormatJsonObject: + type: object + required: + - type + properties: + type: type: string enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: + - json_object + description: 'The type of response format being defined: `json_object`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatJsonSchema: + type: object + required: + - type + - json_schema + properties: + type: type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: + enum: + - json_schema + description: 'The type of response format being defined: `json_schema`' + json_schema: + type: object + properties: + description: + type: string + description: A description of what the response format is for, used by the model to determine how to respond in the format. + name: + type: string + description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + default: false + required: + - name + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatText: + type: object + required: + - type + properties: + type: type: string enum: - - chat.completion - description: The object type, which is always `chat.completion`. - usage: - $ref: '#/components/schemas/OpenAI.CompletionUsage' - description: Represents a chat completion response returned by model, based on the provided input. + - text + description: 'The type of response format being defined: `text`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml index 09be53cee..77edf7597 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml @@ -7,27 +7,6 @@ tags: - name: Images - name: Assistants paths: - /chat/completions: - post: - operationId: createChatCompletion - parameters: [] - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' - - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' - tags: - - Chat - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/AzureCreateChatCompletionRequest' /deployments/{deploymentId}/images/generations: post: operationId: ImageGenerations_Create @@ -86,6 +65,32 @@ paths: application/json: schema: $ref: '#/components/schemas/OpenAI.CreateMessageRequest' + /{deployment_id}/chat/completions: + post: + operationId: createChatCompletion + parameters: + - name: deployment_id + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' + tags: + - Chat + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AzureCreateChatCompletionRequest' security: - ApiKeyAuth: [] - OAuth2Auth: @@ -464,6 +469,43 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. + AzureCompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + - completion_tokens_details + - prompt_tokens_details + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + reasoning_tokens: + type: integer + format: int32 + required: + - reasoning_tokens + prompt_tokens_details: + type: object + properties: + cached_tokens: + type: integer + format: int32 + required: + - cached_tokens AzureContentFilterBlocklistIdResult: type: object required: @@ -896,168 +938,450 @@ components: description: Represents a data source configuration that will use an Azure CosmosDB resource. AzureCreateChatCompletionRequest: type: object + required: + - messages properties: - data_sources: - type: array - items: - $ref: '#/components/schemas/AzureChatDataSource' - description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. - user_security_context: - $ref: '#/components/schemas/AzureUserSecurityContext' - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionRequest' - description: |- - The extended request model for chat completions against the Azure OpenAI service. - This adds the ability to provide data sources for the On Your Data feature. - AzureCreateChatCompletionResponse: - type: object - properties: - prompt_filter_results: + messages: type: array items: - type: object - properties: - prompt_index: - type: integer - format: int32 - description: The index of the input prompt that this content filter result corresponds to. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter results associated with the indexed input prompt. - required: - - prompt_index - - content_filter_results - description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionResponse' - description: |- - The extended top-level chat completion response model for the Azure OpenAI service. - This model adds Responsible AI content filter annotations for prompt input. - AzureImage: - type: object - required: - - prompt_filter_results - - content_filter_results - properties: - prompt_filter_results: - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - content_filter_results: - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' - allOf: - - $ref: '#/components/schemas/OpenAI.Image' - AzureOpenAIChatError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI chat completion request. - AzureOpenAIChatErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIChatError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIDalleError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI image generation request. - AzureOpenAIDalleErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIDalleError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIFile: - type: object - required: - - id - - bytes - - created_at - - filename - - object - - purpose - - status - properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 + additionalProperties: + type: integer + format: int32 nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + data_sources: + type: array + items: + $ref: '#/components/schemas/AzureChatDataSource' + description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. + user_security_context: + $ref: '#/components/schemas/AzureUserSecurityContext' + description: |- + The extended request model for chat completions against the Azure OpenAI service. + This adds the ability to provide data sources for the On Your Data feature. + AzureCreateChatCompletionResponse: + type: object + required: + - id + - choices + - created + - model + - object + - usage + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: type: string enum: - - file - description: The object type, which is always `file`. - purpose: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: type: string enum: - - assistants - - assistants_output + - chat.completion + description: The object type, which is always `chat.completion`. + usage: + $ref: '#/components/schemas/AzureCompletionUsage' + prompt_filter_results: + type: array + items: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt that this content filter result corresponds to. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter results associated with the indexed input prompt. + required: + - prompt_index + - content_filter_results + description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. + description: |- + The extended top-level chat completion response model for the Azure OpenAI service. + This model adds Responsible AI content filter annotations for prompt input. + AzureImage: + type: object + required: + - prompt_filter_results + - content_filter_results + properties: + prompt_filter_results: + $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + content_filter_results: + $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + allOf: + - $ref: '#/components/schemas/OpenAI.Image' + AzureOpenAIChatError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI chat completion request. + AzureOpenAIChatErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIChatError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIDalleError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI image generation request. + AzureOpenAIDalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIDalleError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIFile: + type: object + required: + - id + - bytes + - created_at + - filename + - object + - purpose + - status + properties: + id: + type: string + description: The file identifier, which can be referenced in the API endpoints. + bytes: + type: integer + format: int32 + nullable: true + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + filename: + type: string + description: The name of the file. + object: + type: string + enum: + - file + description: The object type, which is always `file`. + purpose: + type: string + enum: + - assistants + - assistants_output - batch - batch_output - fine-tune @@ -1068,184 +1392,494 @@ components: type: string description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. deprecated: true - status: - type: string - enum: - - uploaded - - pending - - running - - processed - - error - - deleting - - deleted - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - description: Known service API versions for Azure OpenAI. - AzureSearchChatDataSource: + status: + type: string + enum: + - uploaded + - pending + - running + - processed + - error + - deleting + - deleted + AzureOpenAIServiceApiVersion: + type: string + enum: + - 2024-06-01 + - 2024-08-01-preview + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 + - 2024-12-01-preview + description: Known service API versions for Azure OpenAI. + AzureSearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_search + description: The discriminated type identifier, which is always 'azure_search'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + description: The absolute endpoint path for the Azure Search resource to use. + index_name: + type: string + description: The name of the index to use, as specified in the Azure Search resource. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: The authentication mechanism to use with Azure Search. + fields_mapping: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + items: + type: string + description: The names of index fields that should be treated as content. + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + items: + type: string + description: The names of fields that represent vector data. + image_vector_fields: + type: array + items: + type: string + description: The names of fields that represent image vector data. + description: The field mappings to use with the Azure Search resource. + query_type: + type: string + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: + type: string + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + AzureUserSecurityContext: + type: object + properties: + application_name: + type: string + description: The name of the application. Sensitive personal information should not be included in this field. + end_user_id: + type: string + description: This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. + end_user_tenant_id: + type: string + description: The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. + source_ip: + type: string + description: Captures the original client's IP address. + description: User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionTokenLogprobBytesItem: + type: array + items: + type: integer + format: int32 + CompletionUsageCommonBase: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + description: Usage statistics for the completion request. + CreateChatCompletionRequestCommonBase: + type: object + required: + - messages + properties: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + CreateChatCompletionResponseCommonBase: type: object required: - - type - - parameters + - id + - choices + - created + - model + - object properties: - type: + id: type: string - enum: - - azure_search - description: The discriminated type identifier, which is always 'azure_search'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: type: string enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - format: uri - description: The absolute endpoint path for the Azure Search resource to use. - index_name: - type: string - description: The name of the index to use, as specified in the Azure Search resource. - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - description: The authentication mechanism to use with Azure Search. - fields_mapping: - type: object - properties: - title_field: - type: string - description: The name of the index field to use as a title. - url_field: - type: string - description: The name of the index field to use as a URL. - filepath_field: - type: string - description: The name of the index field to use as a filepath. - content_fields: - type: array - items: - type: string - description: The names of index fields that should be treated as content. - content_fields_separator: - type: string - description: The separator pattern that content fields should use. - vector_fields: - type: array - items: - type: string - description: The names of fields that represent vector data. - image_vector_fields: - type: array - items: - type: string - description: The names of fields that represent image vector data. - description: The field mappings to use with the Azure Search resource. - query_type: - type: string - enum: - - simple - - semantic - - vector - - vector_simple_hybrid - - vector_semantic_hybrid - description: The query type for the Azure Search resource to use. - semantic_configuration: - type: string - description: Additional semantic configuration for the query. - filter: - type: string - description: A filter to apply to the search. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' - description: |- - The vectorization source to use with Azure Search. - Supported sources for Azure Search include endpoint, deployment name, and integrated. - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Azure Search data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Search resource. - AzureUserSecurityContext: - type: object - properties: - application_name: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: type: string - description: The name of the application. Sensitive personal information should not be included in this field. - end_user_id: + description: The model used for the chat completion. + service_tier: type: string - description: This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. - end_user_tenant_id: + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: type: string - description: The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. - source_ip: + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: type: string - description: Captures the original client's IP address. - description: User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. - ChatCompletionMessageToolCallsItem: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' - description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -1697,259 +2331,9 @@ components: description: The role of the messages author, in this case `assistant`. name: type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - nullable: true - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestAssistantMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestFunctionMessage: - type: object - required: - - role - - content - - name - properties: - role: - type: string - enum: - - function - description: The role of the messages author, in this case `function`. - content: - type: string - nullable: true - description: The contents of the function message. - name: - type: string - description: The name of the function to call. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - deprecated: true - OpenAI.ChatCompletionRequestMessage: - type: object - required: - - role - properties: - role: - type: string - description: The role of the author of this message. - discriminator: - propertyName: role - mapping: - system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' - user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' - assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' - tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' - function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestMessageContentPartImage: - type: object - required: - - type - - image_url - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - format: uri - description: Either a URL of the image or the base64 encoded image data. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). - default: auto - required: - - url - OpenAI.ChatCompletionRequestMessageContentPartRefusal: - type: object - required: - - type - - refusal - properties: - type: - type: string - enum: - - refusal - description: The type of the content part. - refusal: - type: string - description: The refusal message generated by the model. - OpenAI.ChatCompletionRequestMessageContentPartText: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: The type of the content part. - text: - type: string - description: The text content. - OpenAI.ChatCompletionRequestSystemMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' - description: The contents of the system message. - role: - type: string - enum: - - system - description: The role of the messages author, in this case `system`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestSystemMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestToolMessage: - type: object - required: - - role - - content - - tool_call_id - properties: - role: - type: string - enum: - - tool - description: The role of the messages author, in this case `tool`. - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' - description: The contents of the tool message. - tool_call_id: - type: string - description: Tool call that this message is responding to. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestToolMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestUserMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' - description: The contents of the user message. - x-oaiExpandable: true - role: - type: string - enum: - - user - description: The role of the messages author, in this case `user`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestUserMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' - x-oaiExpandable: true - OpenAI.ChatCompletionResponseMessage: - type: object - required: - - content - - refusal - - role - properties: - content: - type: string - nullable: true - description: The contents of the message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - role: - type: string - enum: - - assistant - description: The role of the author of this message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamOptions: - type: object - properties: - include_usage: - type: boolean - description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' - description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - content: - type: string - nullable: true - description: The contents of the chunk message. + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: type: object properties: @@ -1957,564 +2341,418 @@ components: type: string arguments: type: string + required: + - name + - arguments + nullable: true description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. - OpenAI.ChatCompletionTokenLogprob: - type: object - required: - - token - - logprob - - bytes - - top_logprobs - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - top_logprobs: - type: array - items: - type: object - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: array - items: - type: integer - format: int32 - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - required: - - token - - logprob - - bytes - description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. - OpenAI.ChatCompletionTool: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestAssistantMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestFunctionMessage: type: object required: - - type - - function + - role + - content + - name properties: - type: + role: type: string enum: - function - description: The type of the tool. Currently, only `function` is supported. - function: - $ref: '#/components/schemas/OpenAI.FunctionObject' - OpenAI.ChatCompletionToolChoiceOption: - anyOf: - - type: string - enum: - - none - - auto - - required - - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' - description: |- - Controls which (if any) tool is called by the model. - `none` means the model will not call any tool and instead generates a message. - `auto` means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools. - Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - `none` is the default when no tools are present. `auto` is the default if tools are present. - x-oaiExpandable: true - OpenAI.ChatResponseFormat: + description: The role of the messages author, in this case `function`. + content: + type: string + nullable: true + description: The contents of the function message. + name: + type: string + description: The name of the function to call. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + deprecated: true + OpenAI.ChatCompletionRequestMessage: type: object required: - - type + - role properties: - type: + role: type: string + description: The role of the author of this message. discriminator: - propertyName: type + propertyName: role mapping: - text: '#/components/schemas/OpenAI.ChatResponseFormatText' - json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' - json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' - OpenAI.ChatResponseFormatJsonObject: + system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' + assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' + tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' + function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: - type + - image_url properties: type: type: string enum: - - json_object - description: 'The type of response format being defined: `json_object`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatJsonSchema: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: Either a URL of the image or the base64 encoded image data. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + default: auto + required: + - url + OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: - type - - json_schema + - refusal properties: type: type: string enum: - - json_schema - description: 'The type of response format being defined: `json_schema`' - json_schema: - type: object - properties: - description: - type: string - description: A description of what the response format is for, used by the model to determine how to respond in the format. - name: - type: string - description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - schema: - $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). - default: false - required: - - name - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatText: + - refusal + description: The type of the content part. + refusal: + type: string + description: The refusal message generated by the model. + OpenAI.ChatCompletionRequestMessageContentPartText: type: object required: - type + - text properties: type: type: string enum: - text - description: 'The type of response format being defined: `text`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.CompletionUsage: + description: The type of the content part. + text: + type: string + description: The text content. + OpenAI.ChatCompletionRequestSystemMessage: type: object required: - - completion_tokens - - prompt_tokens - - total_tokens + - content + - role properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens generated by the model. - reasoning_tokens: - type: integer - format: int32 - description: Tokens generated by the model for reasoning. - required: - - audio_tokens - - reasoning_tokens - description: Breakdown of tokens used in a completion. - prompt_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens present in the prompt. - cached_tokens: - type: integer - format: int32 - description: Cached tokens present in the prompt. - required: - - audio_tokens - - cached_tokens - description: Breakdown of tokens used in the prompt. - description: Usage statistics for the completion request. - OpenAI.CreateChatCompletionRequest: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + description: The contents of the system message. + role: + type: string + enum: + - system + description: The role of the messages author, in this case `system`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestSystemMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestToolMessage: type: object required: - - messages - - model + - role + - content + - tool_call_id properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - model: + role: + type: string + enum: + - tool + description: The role of the messages author, in this case `tool`. + content: anyOf: - type: string - - type: string - enum: - - o1-preview - - o1-preview-2024-09-12 - - o1-mini - - o1-mini-2024-09-12 - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - - chatgpt-4o-latest - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0301 - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. - x-oaiTypeLabel: string - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - service_tier: + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' + description: The contents of the tool message. + tool_call_id: type: string - enum: - - auto - - default - nullable: true - description: |- - Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. - default: auto - stop: + description: Tool call that this message is responding to. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestToolMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestUserMessage: + type: object + required: + - content + - role + properties: + content: anyOf: - type: string - type: array items: - type: string + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' + description: The contents of the user message. + x-oaiExpandable: true + role: + type: string + enum: + - user + description: The role of the messages author, in this case `user`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestUserMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + x-oaiExpandable: true + OpenAI.ChatCompletionResponseMessage: + type: object + required: + - content + - refusal + - role + properties: + content: + type: string nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean + description: The contents of the message. + refusal: + type: string nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: + description: The refusal message generated by the model. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + role: + type: string + enum: + - assistant + description: The role of the author of this message. + function_call: type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + description: A chat completion message generated by the model. + OpenAI.ChatCompletionStreamOptions: + type: object + properties: + include_usage: type: boolean - default: true - user: + description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' + description: 'Options for streaming response. Only set this when you set `stream: true`.' + OpenAI.ChatCompletionStreamResponseDelta: + type: object + properties: + content: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + nullable: true + description: The contents of the chunk message. function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true - x-oaiExpandable: true - functions: + tool_calls: type: array items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - OpenAI.CreateChatCompletionResponse: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + description: A chat completion delta generated by streamed model responses. + OpenAI.ChatCompletionTokenLogprob: type: object required: - - id - - choices - - created - - model - - object + - token + - logprob + - bytes + - top_logprobs properties: - id: + token: type: string - description: A unique identifier for the chat completion. - choices: + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + top_logprobs: type: array items: type: object properties: - finish_reason: + token: type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: array + items: + type: integer + format: int32 nullable: true - description: Log probability information for the choice. + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: + - token + - logprob + - bytes + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + OpenAI.ChatCompletionTool: + type: object + required: + - type + - function + properties: + type: type: string - description: The model used for the chat completion. - service_tier: + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + OpenAI.ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - auto + - required + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' + description: |- + Controls which (if any) tool is called by the model. + `none` means the model will not call any tool and instead generates a message. + `auto` means the model can pick between generating a message or calling one or more tools. + `required` means the model must call one or more tools. + Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + + `none` is the default when no tools are present. `auto` is the default if tools are present. + x-oaiExpandable: true + OpenAI.ChatResponseFormat: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/OpenAI.ChatResponseFormatText' + json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' + json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' + OpenAI.ChatResponseFormatJsonObject: + type: object + required: + - type + properties: + type: type: string enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: + - json_object + description: 'The type of response format being defined: `json_object`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatJsonSchema: + type: object + required: + - type + - json_schema + properties: + type: type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: + enum: + - json_schema + description: 'The type of response format being defined: `json_schema`' + json_schema: + type: object + properties: + description: + type: string + description: A description of what the response format is for, used by the model to determine how to respond in the format. + name: + type: string + description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + default: false + required: + - name + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatText: + type: object + required: + - type + properties: + type: type: string enum: - - chat.completion - description: The object type, which is always `chat.completion`. - usage: - $ref: '#/components/schemas/OpenAI.CompletionUsage' - description: Represents a chat completion response returned by model, based on the provided input. + - text + description: 'The type of response format being defined: `text`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' OpenAI.CreateImageRequest: type: object required: diff --git a/.typespec.azure/chat/models.request.tsp b/.typespec.azure/chat/models.request.tsp index f4e7b4c81..f31d1648e 100644 --- a/.typespec.azure/chat/models.request.tsp +++ b/.typespec.azure/chat/models.request.tsp @@ -9,12 +9,18 @@ using TypeSpec.Versioning; namespace AzureOpenAI; +@withoutOmittedProperties("model") +@withoutOmittedProperties("service_tier") +model CreateChatCompletionRequestCommonBase + is OpenAI.CreateChatCompletionRequest; + /** * The extended request model for chat completions against the Azure OpenAI service. * This adds the ability to provide data sources for the On Your Data feature. */ -model AzureCreateChatCompletionRequest - extends OpenAI.CreateChatCompletionRequest { +model AzureCreateChatCompletionRequest { + ...CreateChatCompletionRequestCommonBase; + /** * The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. */ diff --git a/.typespec.azure/chat/models.response.tsp b/.typespec.azure/chat/models.response.tsp index 9796fea44..58b348584 100644 --- a/.typespec.azure/chat/models.response.tsp +++ b/.typespec.azure/chat/models.response.tsp @@ -3,12 +3,32 @@ import "../common"; namespace AzureOpenAI; +@withoutOmittedProperties("completion_tokens_details") +@withoutOmittedProperties("prompt_tokens_details") +model CompletionUsageCommonBase is OpenAI.CompletionUsage; + +model AzureCompletionUsage { + ...CompletionUsageCommonBase; + completion_tokens_details: { + reasoning_tokens: int32; + }; + prompt_tokens_details: { + cached_tokens: int32; + }; +} + +@withoutOmittedProperties("usage") +model CreateChatCompletionResponseCommonBase + is OpenAI.CreateChatCompletionResponse; + /** * The extended top-level chat completion response model for the Azure OpenAI service. * This model adds Responsible AI content filter annotations for prompt input. */ -model AzureCreateChatCompletionResponse - extends OpenAI.CreateChatCompletionResponse { +model AzureCreateChatCompletionResponse { + ...CreateChatCompletionResponseCommonBase; + usage: AzureCompletionUsage; + /** * The Responsible AI content filter annotations associated with prompt inputs into chat completions. */ diff --git a/.typespec.azure/chat/operations.tsp b/.typespec.azure/chat/operations.tsp index 138a7283d..0fafc04f7 100644 --- a/.typespec.azure/chat/operations.tsp +++ b/.typespec.azure/chat/operations.tsp @@ -11,13 +11,14 @@ using OpenAI; namespace AzureOpenAI; -@route("/chat") +@route("{deployment_id}/chat") interface AzureChat { @route("completions") @post @operationId("createChatCompletion") @tag("Chat") createChatCompletion( - ...AzureCreateChatCompletionRequest, + @path deployment_id: string, + @body request: AzureCreateChatCompletionRequest, ): AzureCreateChatCompletionResponse | AzureOpenAIChatErrorResponse; } From f944259b327c0ebe74cb1ad135f5576894f17d67 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 16 Jan 2025 15:21:18 -0800 Subject: [PATCH 08/44] squashed merge for retarget --- .../src/Custom/Files/AzureOpenAIFile.cs | 2 +- ...AzureOpenAIFileCollection.Serialization.cs | 28 +- .../Custom/Files/AzureOpenAIFileCollection.cs | 16 +- .dotnet/api/OpenAI.netstandard2.0.cs | 136 +- .../Internal/GeneratorStubs.Internal.cs | 6 +- .../ChatCompletionOptions.Serialization.cs | 37 + .../src/Custom/Chat/ChatCompletionOptions.cs | 11 + .dotnet/src/Custom/Chat/ChatMessage.cs | 11 + .dotnet/src/Custom/Chat/ChatMessageRole.cs | 15 + .../Chat/ChatOutputTokenUsageDetails.cs | 6 + .../src/Custom/Chat/ChatReasoningEffort.cs | 9 + .../DeveloperChatMessage.Serialization.cs | 45 + .../src/Custom/Chat/DeveloperChatMessage.cs | 59 + .../Custom/Chat/Internal/GeneratorStubs.cs | 5 + .../src/Custom/Chat/OpenAIChatModelFactory.cs | 9 +- .../Custom/Files/Internal/GeneratorStubs.cs | 3 - .../OpenAIFileCollection.Serialization.cs | 24 +- .../src/Custom/Files/OpenAIFileCollection.cs | 26 +- .../Custom/Files/OpenAIFilesModelFactory.cs | 7 +- .../FineTuning/Internal/GeneratorStubs.cs | 29 + .../ConversationIncompleteReason.cs | 11 + .../ConversationInputTokenUsageDetails.cs | 21 + .../ConversationOutputTokenUsageDetails.cs | 18 + .../ConversationResponseOptions.cs | 54 + .../ConversationSessionOptions.cs | 3 + .../ConversationStatusDetails.cs | 12 +- .../RealtimeConversation/GeneratorStubs.cs | 2 - .../Internal/GeneratorStubs.cs | 8 +- ...altimeClientEventResponseCreateResponse.cs | 46 - .../RealtimeConversationSession.cs | 37 +- .../ResponseConversationSelection.cs | 14 + .../ConversationResponseStartedUpdate.cs | 2 +- .../ChatCompletionOptions.Serialization.cs | 35 + .../Generated/Models/ChatCompletionOptions.cs | 4 +- ...hatInputTokenUsageDetails.Serialization.cs | 12 +- .../Models/ChatInputTokenUsageDetails.cs | 4 +- .../Models/ChatMessage.Serialization.cs | 2 + .../Models/ChatMessageRole.Serialization.cs | 5 + ...atOutputTokenUsageDetails.Serialization.cs | 44 +- .../Models/ChatOutputTokenUsageDetails.cs | 8 +- .../Generated/Models/ChatReasoningEffort.cs | 47 + .../src/Generated/Models/ChatResponseVoice.cs | 20 +- .../Models/ConversationIncompleteReason.cs | 50 + ...ionInputTokenUsageDetails.Serialization.cs | 50 +- .../ConversationInputTokenUsageDetails.cs | 19 +- ...onOutputTokenUsageDetails.Serialization.cs | 26 +- .../ConversationOutputTokenUsageDetails.cs | 14 +- ...versationResponseOptions.Serialization.cs} | 220 +- .../Models/ConversationResponseOptions.cs | 57 + ...onversationSessionOptions.Serialization.cs | 16 + .../Models/ConversationSessionOptions.cs | 3 +- .../Generated/Models/ConversationStatus.cs | 9 +- ...ConversationStatusDetails.Serialization.cs | 58 +- .../Models/ConversationStatusDetails.cs | 9 +- .../ConversationTokenUsage.Serialization.cs | 46 +- .../Models/ConversationTokenUsage.cs | 15 +- .../src/Generated/Models/ConversationVoice.cs | 19 +- .../DeveloperChatMessage.Serialization.cs | 128 + .../Generated/Models/DeveloperChatMessage.cs | 17 + .../Models/FineTuningJob.Serialization.cs | 16 + .dotnet/src/Generated/Models/FineTuningJob.cs | 5 +- .../FineTuningJobEvent.Serialization.cs | 53 +- .../Generated/Models/FineTuningJobEvent.cs | 12 +- ...eTuningJobHyperparameters.Serialization.cs | 18 +- ...ngJobHyperparametersBatchSizeChoiceEnum.cs | 41 - ...ametersLearningRateMultiplierChoiceEnum.cs | 41 - ...ningJobHyperparametersNEpochsChoiceEnum.cs | 41 - .../Models/FineTuningOptions.Serialization.cs | 16 + .../src/Generated/Models/FineTuningOptions.cs | 5 +- .../Generated/Models/GeneratedSpeechVoice.cs | 9 + .../Models/HyperparameterBatchSize.cs | 41 - .../Models/HyperparameterCycleCount.cs | 41 - .../Models/HyperparameterLearningRate.cs | 41 - .../HyperparameterOptions.Serialization.cs | 40 +- .../Generated/Models/HyperparameterOptions.cs | 8 +- .../InternalCreateAssistantRequestModel.cs | 3 + ...nternalCreateChatCompletionRequestModel.cs | 24 +- .../Models/InternalCreateRunRequestModel.cs | 3 + .../InternalCreateThreadAndRunRequestModel.cs | 3 + ...isedMethodHyperparameters.Serialization.cs | 196 + ...FineTuneSupervisedMethodHyperparameters.cs | 38 + .../Models/InternalFineTuningJobEventType.cs | 44 + .../Models/InternalListFilesResponseObject.cs | 41 - ...InternalPredictionContent.Serialization.cs | 163 + .../Models/InternalPredictionContent.cs | 39 + .../Models/InternalPredictionContentType.cs | 41 + ...ClientEventResponseCancel.Serialization.cs | 13 +- ...ternalRealtimeClientEventResponseCancel.cs | 5 +- ...ClientEventResponseCreate.Serialization.cs | 14 +- ...ternalRealtimeClientEventResponseCreate.cs | 10 +- .../InternalRealtimeRequestSessionModel.cs | 53 + .../InternalRealtimeResponse.Serialization.cs | 106 +- .../Models/InternalRealtimeResponse.cs | 24 +- .../Models/InternalRealtimeResponseOptions.cs | 54 - ...esponseStatusDetailsError.Serialization.cs | 152 + ...ernalRealtimeResponseStatusDetailsError.cs | 35 + ...ternalRealtimeResponseStatusDetailsType.cs | 50 + ...timeServerEventErrorError.Serialization.cs | 56 +- .../InternalRealtimeServerEventErrorError.cs | 4 +- ...ToolCallsFileSearchObject.Serialization.cs | 6 +- ...ltaStepDetailsToolCallsFileSearchObject.cs | 6 +- ...ileSearchObjectFileSearch.Serialization.cs | 170 - ...ailsToolCallsFileSearchObjectFileSearch.cs | 35 - ...etailsToolCallsCodeObject.Serialization.cs | 17 +- ...ternalRunStepDetailsToolCallsCodeObject.cs | 4 +- ...ToolCallsFileSearchObject.Serialization.cs | 17 +- ...RunStepDetailsToolCallsFileSearchObject.cs | 4 +- ...lsToolCallsFunctionObject.Serialization.cs | 17 +- ...alRunStepDetailsToolCallsFunctionObject.cs | 4 +- ...FineTuneChatRequestInput.Serialization.cs} | 50 +- ...> InternalTodoFineTuneChatRequestInput.cs} | 6 +- ...neCompletionRequestInput.Serialization.cs} | 50 +- ...rnalTodoFineTuneCompletionRequestInput.cs} | 6 +- ...rnalTodoFineTuneDPOMethod.Serialization.cs | 145 + .../Models/InternalTodoFineTuneDPOMethod.cs | 32 + ...eDPOMethodHyperparameters.Serialization.cs | 218 + ...nalTodoFineTuneDPOMethodHyperparameters.cs | 41 + ...nternalTodoFineTuneMethod.Serialization.cs | 175 + .../Models/InternalTodoFineTuneMethod.cs | 38 + .../Models/InternalTodoFineTuneMethodType.cs | 44 + ...oFineTuneSupervisedMethod.Serialization.cs | 145 + .../InternalTodoFineTuneSupervisedMethod.cs | 32 + .../OpenAIFileCollection.Serialization.cs | 17 +- .../Models/ResponseConversationSelection.cs | 44 + ...epFileSearchResultContent.Serialization.cs | 4 + .../src/Generated/Models/RunStepToolCall.cs | 1 + ...timeResponseStatusDetails.Serialization.cs | 105 - .../UnknownRealtimeResponseStatusDetails.cs | 16 - .dotnet/src/Generated/OpenAIModelFactory.cs | 63 +- .dotnet/tests/Chat/ChatTests.cs | 53 + .../RealtimeConversation/ConversationTests.cs | 74 +- .openapi3/openapi3-openai.yaml | 2299 ++++-- .scripts/Update-ClientModel.ps1 | 4 +- .typespec/administration/models.tsp | 405 ++ .typespec/assistants/models.tsp | 13 +- .typespec/audio/models.tsp | 19 +- .typespec/chat/models.tsp | 180 +- .typespec/common/models.tsp | 25 +- .typespec/completions/models.tsp | 8 +- .typespec/embeddings/models.tsp | 6 +- .typespec/files/models.tsp | 5 +- .typespec/fine-tuning/client.tsp | 8 +- .typespec/fine-tuning/custom.tsp | 45 - .typespec/fine-tuning/models.tsp | 158 +- .typespec/images/models.tsp | 6 +- .typespec/moderations/models.tsp | 2 +- .typespec/organization/models.tsp | 18 + .typespec/realtime/client.tsp | 1 - .typespec/realtime/custom.tsp | 92 +- .typespec/realtime/models.tsp | 822 ++- .typespec/runs/models.tsp | 27 +- .typespec/streaming/models.tsp | 2 +- .typespec/uploads/models.tsp | 24 + README.md | 15 +- openapi3-original.yaml | 6142 ++++++++++++++--- 155 files changed, 12402 insertions(+), 2811 deletions(-) create mode 100644 .dotnet/src/Custom/Chat/ChatReasoningEffort.cs create mode 100644 .dotnet/src/Custom/Chat/DeveloperChatMessage.Serialization.cs create mode 100644 .dotnet/src/Custom/Chat/DeveloperChatMessage.cs create mode 100644 .dotnet/src/Custom/RealtimeConversation/ConversationIncompleteReason.cs create mode 100644 .dotnet/src/Custom/RealtimeConversation/ConversationInputTokenUsageDetails.cs create mode 100644 .dotnet/src/Custom/RealtimeConversation/ConversationOutputTokenUsageDetails.cs create mode 100644 .dotnet/src/Custom/RealtimeConversation/ConversationResponseOptions.cs delete mode 100644 .dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeClientEventResponseCreateResponse.cs create mode 100644 .dotnet/src/Custom/RealtimeConversation/ResponseConversationSelection.cs create mode 100644 .dotnet/src/Generated/Models/ChatReasoningEffort.cs create mode 100644 .dotnet/src/Generated/Models/ConversationIncompleteReason.cs rename .dotnet/src/Generated/Models/{InternalRealtimeResponseOptions.Serialization.cs => ConversationResponseOptions.Serialization.cs} (52%) create mode 100644 .dotnet/src/Generated/Models/ConversationResponseOptions.cs create mode 100644 .dotnet/src/Generated/Models/DeveloperChatMessage.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/DeveloperChatMessage.cs delete mode 100644 .dotnet/src/Generated/Models/FineTuningJobHyperparametersBatchSizeChoiceEnum.cs delete mode 100644 .dotnet/src/Generated/Models/FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum.cs delete mode 100644 .dotnet/src/Generated/Models/FineTuningJobHyperparametersNEpochsChoiceEnum.cs delete mode 100644 .dotnet/src/Generated/Models/HyperparameterBatchSize.cs delete mode 100644 .dotnet/src/Generated/Models/HyperparameterCycleCount.cs delete mode 100644 .dotnet/src/Generated/Models/HyperparameterLearningRate.cs create mode 100644 .dotnet/src/Generated/Models/InternalFineTuneSupervisedMethodHyperparameters.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalFineTuneSupervisedMethodHyperparameters.cs create mode 100644 .dotnet/src/Generated/Models/InternalFineTuningJobEventType.cs delete mode 100644 .dotnet/src/Generated/Models/InternalListFilesResponseObject.cs create mode 100644 .dotnet/src/Generated/Models/InternalPredictionContent.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalPredictionContent.cs create mode 100644 .dotnet/src/Generated/Models/InternalPredictionContentType.cs create mode 100644 .dotnet/src/Generated/Models/InternalRealtimeRequestSessionModel.cs delete mode 100644 .dotnet/src/Generated/Models/InternalRealtimeResponseOptions.cs create mode 100644 .dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsError.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsError.cs create mode 100644 .dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsType.cs delete mode 100644 .dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs delete mode 100644 .dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.cs rename .dotnet/src/Generated/Models/{InternalFinetuneChatRequestInput.Serialization.cs => InternalTodoFineTuneChatRequestInput.Serialization.cs} (71%) rename .dotnet/src/Generated/Models/{InternalFinetuneChatRequestInput.cs => InternalTodoFineTuneChatRequestInput.cs} (76%) rename .dotnet/src/Generated/Models/{InternalFinetuneCompletionRequestInput.Serialization.cs => InternalTodoFineTuneCompletionRequestInput.Serialization.cs} (56%) rename .dotnet/src/Generated/Models/{InternalFinetuneCompletionRequestInput.cs => InternalTodoFineTuneCompletionRequestInput.cs} (71%) create mode 100644 .dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethod.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethod.cs create mode 100644 .dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethodHyperparameters.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethodHyperparameters.cs create mode 100644 .dotnet/src/Generated/Models/InternalTodoFineTuneMethod.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalTodoFineTuneMethod.cs create mode 100644 .dotnet/src/Generated/Models/InternalTodoFineTuneMethodType.cs create mode 100644 .dotnet/src/Generated/Models/InternalTodoFineTuneSupervisedMethod.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalTodoFineTuneSupervisedMethod.cs create mode 100644 .dotnet/src/Generated/Models/ResponseConversationSelection.cs delete mode 100644 .dotnet/src/Generated/Models/UnknownRealtimeResponseStatusDetails.Serialization.cs delete mode 100644 .dotnet/src/Generated/Models/UnknownRealtimeResponseStatusDetails.cs create mode 100644 .typespec/organization/models.tsp diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.cs index d58dcd400..e911e77d3 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.cs @@ -61,7 +61,7 @@ internal partial class AzureOpenAIFile : OpenAIFile internal AzureOpenAIFile(string id, int? bytes, DateTimeOffset createdAt, string filename, string purpose, AzureOpenAIFileStatus azureStatus) : base(id, createdAt, filename, purpose.ToFilePurpose(), bytes, azureStatus.ToFileStatus()) { - _object = InternalListFilesResponseObject.List.ToString(); + _object = "file"; _purpose = purpose; _azureStatus = azureStatus; } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.Serialization.cs index 29d07b73f..cfc351f25 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.Serialization.cs @@ -34,8 +34,11 @@ internal static AzureOpenAIFileCollection DeserializeAzureOpenAIFileCollection(J return null; } IReadOnlyList data = default; - InternalListFilesResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; + string @object = default; + string firstId = default; + string lastId = default; + bool hasMore = false; + IDictionary additionalBinaryDataProperties = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { @@ -51,7 +54,22 @@ internal static AzureOpenAIFileCollection DeserializeAzureOpenAIFileCollection(J } if (property.NameEquals("object"u8)) { - @object = new InternalListFilesResponseObject(property.Value.GetString()); + @object = property.Value.GetString(); + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); continue; } if (true) @@ -59,8 +77,8 @@ internal static AzureOpenAIFileCollection DeserializeAzureOpenAIFileCollection(J rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new AzureOpenAIFileCollection(data, @object, serializedAdditionalRawData); + additionalBinaryDataProperties = rawDataDictionary; + return new AzureOpenAIFileCollection(data, @object, firstId, lastId, hasMore, additionalBinaryDataProperties); } void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.cs index 7fe8213fe..d5d6e55bf 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.cs @@ -11,19 +11,25 @@ internal partial class AzureOpenAIFileCollection : OpenAIFileCollection internal new IDictionary SerializedAdditionalRawData { get; } = new ChangeTrackingDictionary(); - internal InternalListFilesResponseObject Object { get; } + internal string Object { get; } internal AzureOpenAIFileCollection() : this( new ChangeTrackingList(), - InternalListFilesResponseObject.List, + "list", + firstId: null, + lastId: null, + hasMore: false, new ChangeTrackingDictionary()) { } internal AzureOpenAIFileCollection( IEnumerable files, - InternalListFilesResponseObject @object, - IDictionary serializedAdditionalRawData) - : base(files.Cast().ToList(), @object, serializedAdditionalRawData) + string @object, + string firstId, + string lastId, + bool hasMore, + IDictionary additionalBinaryDataProperties) + : base(files.Cast().ToList(), @object, firstId, lastId, hasMore, additionalBinaryDataProperties) { } } \ No newline at end of file diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 8ed7eb820..14dd1f213 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1050,10 +1050,13 @@ public class AudioTranslationOptions : IJsonModel, IPer public readonly partial struct GeneratedSpeechVoice : IEquatable { public GeneratedSpeechVoice(string value); public static GeneratedSpeechVoice Alloy { get; } + public static GeneratedSpeechVoice Ash { get; } + public static GeneratedSpeechVoice Coral { get; } public static GeneratedSpeechVoice Echo { get; } public static GeneratedSpeechVoice Fable { get; } public static GeneratedSpeechVoice Nova { get; } public static GeneratedSpeechVoice Onyx { get; } + public static GeneratedSpeechVoice Sage { get; } public static GeneratedSpeechVoice Shimmer { get; } public readonly bool Equals(GeneratedSpeechVoice other); [EditorBrowsable(EditorBrowsableState.Never)] @@ -1207,7 +1210,9 @@ public class ChatCompletionOptions : IJsonModel, IPersist public IDictionary LogitBiases { get; } public int? MaxOutputTokenCount { get; set; } public IDictionary Metadata { get; } + public ChatMessageContent PredictedContent { get; set; } public float? PresencePenalty { get; set; } + public ChatReasoningEffort? ReasoningEffort { get; set; } public ChatResponseFormat ResponseFormat { get; set; } public long? Seed { get; set; } public IList StopSequences { get; } @@ -1296,6 +1301,9 @@ public class ChatMessage : IJsonModel, IPersistableModel contentParts); public static AssistantChatMessage CreateAssistantMessage(IEnumerable toolCalls); public static AssistantChatMessage CreateAssistantMessage(string content); + public static DeveloperChatMessage CreateDeveloperMessage(params ChatMessageContentPart[] contentParts); + public static DeveloperChatMessage CreateDeveloperMessage(IEnumerable contentParts); + public static DeveloperChatMessage CreateDeveloperMessage(string content); [Obsolete("This method is obsolete. Please use CreateToolMessage instead.")] public static FunctionChatMessage CreateFunctionMessage(string functionName, string content); public static SystemChatMessage CreateSystemMessage(params ChatMessageContentPart[] contentParts); @@ -1344,10 +1352,11 @@ public enum ChatMessageContentPartKind { } public enum ChatMessageRole { System = 0, - User = 1, - Assistant = 2, - Tool = 3, - Function = 4 + Developer = 1, + User = 2, + Assistant = 3, + Tool = 4, + Function = 5 } public readonly partial struct ChatOutputAudioFormat : IEquatable { public ChatOutputAudioFormat(string value); @@ -1368,10 +1377,27 @@ public enum ChatMessageRole { } public class ChatOutputTokenUsageDetails : IJsonModel, IPersistableModel { public int AudioTokenCount { get; } + public int PredictionAcceptedTokenCount { get; } + public int PredictionRejectedTokenCount { get; } public int ReasoningTokenCount { get; } public static explicit operator ChatOutputTokenUsageDetails(ClientResult result); public static implicit operator BinaryContent(ChatOutputTokenUsageDetails chatOutputTokenUsageDetails); } + public readonly partial struct ChatReasoningEffort : IEquatable { + public ChatReasoningEffort(string value); + public static ChatReasoningEffort High { get; } + public static ChatReasoningEffort Low { get; } + public static ChatReasoningEffort Medium { get; } + public readonly bool Equals(ChatReasoningEffort other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(ChatReasoningEffort left, ChatReasoningEffort right); + public static implicit operator ChatReasoningEffort(string value); + public static bool operator !=(ChatReasoningEffort left, ChatReasoningEffort right); + public override readonly string ToString(); + } public class ChatResponseAudio : IJsonModel, IPersistableModel { public BinaryData Data { get; } public DateTimeOffset ExpiresAt { get; } @@ -1396,11 +1422,13 @@ public class ChatResponseFormat : IJsonModel, IPersistableMo public readonly partial struct ChatResponseVoice : IEquatable { public ChatResponseVoice(string value); public static ChatResponseVoice Alloy { get; } + public static ChatResponseVoice Ash { get; } + public static ChatResponseVoice Ballad { get; } + public static ChatResponseVoice Coral { get; } public static ChatResponseVoice Echo { get; } - public static ChatResponseVoice Fable { get; } - public static ChatResponseVoice Nova { get; } - public static ChatResponseVoice Onyx { get; } + public static ChatResponseVoice Sage { get; } public static ChatResponseVoice Shimmer { get; } + public static ChatResponseVoice Verse { get; } public readonly bool Equals(ChatResponseVoice other); [EditorBrowsable(EditorBrowsableState.Never)] public override readonly bool Equals(object obj); @@ -1468,6 +1496,18 @@ public class ChatToolChoice : IJsonModel, IPersistableModel, IPersistableModel { + public DeveloperChatMessage(params ChatMessageContentPart[] contentParts); + public DeveloperChatMessage(IEnumerable contentParts); + public DeveloperChatMessage(string content); + public string ParticipantName { get; set; } + protected override ChatMessage JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options); + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options); + public new static explicit operator DeveloperChatMessage(ClientResult result); + public static implicit operator BinaryContent(DeveloperChatMessage developerChatMessage); + protected override ChatMessage PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options); + } [Obsolete("This class is obsolete. Please use ToolChatMessage instead.")] public class FunctionChatMessage : ChatMessage, IJsonModel, IPersistableModel { public FunctionChatMessage(string functionName, string content); @@ -1482,7 +1522,7 @@ public class FunctionChatMessage : ChatMessage, IJsonModel, public static class OpenAIChatModelFactory { public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatResponseAudio responseAudio = null); public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = 0, int cachedTokenCount = 0); - public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = 0, int audioTokenCount = 0); + public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = 0, int audioTokenCount = 0, int predictionAcceptedTokenCount = 0, int predictionRejectedTokenCount = 0); public static ChatResponseAudio ChatResponseAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default); public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null); public static ChatTokenTopLogProbabilityDetails ChatTokenTopLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null); @@ -1722,7 +1762,7 @@ public class OpenAIFileCollection : ObjectModel.ReadOnlyCollection, } public static class OpenAIFilesModelFactory { public static FileDeletionResult FileDeletionResult(string fileId = null, bool deleted = false); - public static OpenAIFileCollection OpenAIFileCollection(IEnumerable items = null); + public static OpenAIFileCollection OpenAIFileCollection(IEnumerable items = null, string firstId = null, string lastId = null, bool hasMore = false); public static OpenAIFile OpenAIFileInfo(string id = null, int? sizeInBytes = null, DateTimeOffset createdAt = default, string filename = null, FilePurpose purpose = FilePurpose.Assistants, FileStatus status = FileStatus.Uploaded, string statusDetails = null); } } @@ -2081,6 +2121,22 @@ public class ConversationFunctionTool : ConversationTool, IJsonModel { + public ConversationIncompleteReason(string value); + public static ConversationIncompleteReason ClientCancelled { get; } + public static ConversationIncompleteReason ContentFilter { get; } + public static ConversationIncompleteReason MaxOutputTokens { get; } + public static ConversationIncompleteReason TurnDetected { get; } + public readonly bool Equals(ConversationIncompleteReason other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(ConversationIncompleteReason left, ConversationIncompleteReason right); + public static implicit operator ConversationIncompleteReason(string value); + public static bool operator !=(ConversationIncompleteReason left, ConversationIncompleteReason right); + public override readonly string ToString(); + } public class ConversationInputAudioClearedUpdate : ConversationUpdate, IJsonModel, IPersistableModel { protected override ConversationUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options); protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options); @@ -2120,9 +2176,9 @@ public class ConversationInputSpeechStartedUpdate : ConversationUpdate, IJsonMod protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options); } public class ConversationInputTokenUsageDetails : IJsonModel, IPersistableModel { - public int AudioTokens { get; } - public int CachedTokens { get; } - public int TextTokens { get; } + public int AudioTokenCount { get; } + public int CachedTokenCount { get; } + public int TextTokenCount { get; } public static explicit operator ConversationInputTokenUsageDetails(ClientResult result); public static implicit operator BinaryContent(ConversationInputTokenUsageDetails conversationInputTokenUsageDetails); } @@ -2338,8 +2394,8 @@ public class ConversationMaxTokensChoice : IJsonModel, IPersistableModel { - public int AudioTokens { get; } - public int TextTokens { get; } + public int AudioTokenCount { get; } + public int TextTokenCount { get; } public static explicit operator ConversationOutputTokenUsageDetails(ClientResult result); public static implicit operator BinaryContent(ConversationOutputTokenUsageDetails conversationOutputTokenUsageDetails); } @@ -2375,6 +2431,21 @@ public class ConversationResponseFinishedUpdate : ConversationUpdate, IJsonModel protected override ConversationUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options); protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options); } + public class ConversationResponseOptions : IJsonModel, IPersistableModel { + public ConversationContentModalities ContentModalities { get; set; } + public ResponseConversationSelection? ConversationSelection { get; set; } + public string Instructions { get; set; } + public ConversationMaxTokensChoice MaxOutputTokens { get; set; } + public IDictionary Metadata { get; set; } + public ConversationAudioFormat? OutputAudioFormat { get; set; } + public IList OverrideItems { get; } + public float? Temperature { get; set; } + public ConversationToolChoice ToolChoice { get; set; } + public IList Tools { get; } + public ConversationVoice? Voice { get; set; } + public static explicit operator ConversationResponseOptions(ClientResult result); + public static implicit operator BinaryContent(ConversationResponseOptions conversationResponseOptions); + } public class ConversationResponseStartedUpdate : ConversationUpdate, IJsonModel, IPersistableModel { public IReadOnlyList CreatedItems { get; } public string ResponseId { get; } @@ -2451,7 +2522,6 @@ public class ConversationSessionStartedUpdate : ConversationUpdate, IJsonModel, IPersistableModel { + public class ConversationStatusDetails : IJsonModel, IPersistableModel { + public string ErrorCode { get; } + public string ErrorType { get; } + public ConversationIncompleteReason? IncompleteReason { get; } public ConversationStatus StatusKind { get; } public static explicit operator ConversationStatusDetails(ClientResult result); public static implicit operator BinaryContent(ConversationStatusDetails conversationStatusDetails); } public class ConversationTokenUsage : IJsonModel, IPersistableModel { public ConversationInputTokenUsageDetails InputTokenDetails { get; } - public int InputTokens { get; } + public int? InputTokens { get; } public ConversationOutputTokenUsageDetails OutputTokenDetails { get; } - public int OutputTokens { get; } - public int TotalTokens { get; } + public int? OutputTokens { get; } + public int? TotalTokens { get; } public static explicit operator ConversationTokenUsage(ClientResult result); public static implicit operator BinaryContent(ConversationTokenUsage conversationTokenUsage); } @@ -2575,8 +2648,13 @@ public enum ConversationUpdateKind { public readonly partial struct ConversationVoice : IEquatable { public ConversationVoice(string value); public static ConversationVoice Alloy { get; } + public static ConversationVoice Ash { get; } + public static ConversationVoice Ballad { get; } + public static ConversationVoice Coral { get; } public static ConversationVoice Echo { get; } + public static ConversationVoice Sage { get; } public static ConversationVoice Shimmer { get; } + public static ConversationVoice Verse { get; } public readonly bool Equals(ConversationVoice other); [EditorBrowsable(EditorBrowsableState.Never)] public override readonly bool Equals(object obj); @@ -2637,13 +2715,27 @@ public class RealtimeConversationSession : IDisposable { public virtual void SendInputAudio(Stream audio, CancellationToken cancellationToken = default); public virtual Task SendInputAudioAsync(BinaryData audio, CancellationToken cancellationToken = default); public virtual Task SendInputAudioAsync(Stream audio, CancellationToken cancellationToken = default); - public virtual void StartResponse(ConversationSessionOptions sessionOptionOverrides, CancellationToken cancellationToken = default); - public virtual void StartResponse(CancellationToken cancellationToken = default); - public virtual Task StartResponseAsync(ConversationSessionOptions sessionOptionOverrides, CancellationToken cancellationToken = default); + public virtual void StartResponse(ConversationResponseOptions options, CancellationToken cancellationToken = default); + public void StartResponse(CancellationToken cancellationToken = default); + public virtual Task StartResponseAsync(ConversationResponseOptions options, CancellationToken cancellationToken = default); public virtual Task StartResponseAsync(CancellationToken cancellationToken = default); public virtual void TruncateItem(string itemId, int contentPartIndex, TimeSpan audioDuration, CancellationToken cancellationToken = default); public virtual Task TruncateItemAsync(string itemId, int contentPartIndex, TimeSpan audioDuration, CancellationToken cancellationToken = default); } + public readonly partial struct ResponseConversationSelection : IEquatable { + public ResponseConversationSelection(string value); + public static ResponseConversationSelection Auto { get; } + public static ResponseConversationSelection None { get; } + public readonly bool Equals(ResponseConversationSelection other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(ResponseConversationSelection left, ResponseConversationSelection right); + public static implicit operator ResponseConversationSelection(string value); + public static bool operator !=(ResponseConversationSelection left, ResponseConversationSelection right); + public override readonly string ToString(); + } } namespace OpenAI.VectorStores { public class AddFileToVectorStoreOperation : OperationResult { diff --git a/.dotnet/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs b/.dotnet/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs index 5748a3ab3..0fc14de68 100644 --- a/.dotnet/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs +++ b/.dotnet/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs @@ -206,7 +206,11 @@ internal partial class InternalRunStepDeltaStepDetailsMessageCreationObject { } internal partial class InternalRunStepDeltaStepDetailsToolCallsObject { } [CodeGenModel("RunStepDeltaStepDetailsToolCallsFileSearchObject")] -internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObject { } +internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObject +{ + [CodeGenMember("FileSearch")] + public InternalRunStepDetailsToolCallsFileSearchObjectFileSearch FileSearch { get; set; } +} [CodeGenModel("RunStepDeltaStepDetailsToolCallsFunctionObject")] internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObject { } diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs index cc003e4b4..4ead2afc5 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs @@ -95,4 +95,41 @@ private static void DeserializeLogitBiasesValue(JsonProperty property, ref IDict logitBias = dictionary; } } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void SerializePredictedContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + if (PredictedContent is not null) + { + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(InternalPredictionContentType.Content.ToString()); + writer.WritePropertyName("content"u8); + writer.WriteObjectValue(PredictedContent, options); + writer.WriteEndObject(); + } + else + { + writer.WriteNullValue(); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static void DeserializePredictedContentValue(JsonProperty property, ref ChatMessageContent predictedContent) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + predictedContent = null; + } + else + { + foreach (JsonProperty predictionProperty in property.Value.EnumerateObject()) + { + if (predictionProperty.NameEquals("content"u8)) + { + ChatMessage.DeserializeContentValue(predictionProperty, ref predictedContent); + } + } + } + } } diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs index 78788dda5..cbcccf8ff 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs @@ -12,6 +12,7 @@ namespace OpenAI.Chat; [CodeGenSerialization(nameof(Messages), SerializationValueHook = nameof(SerializeMessagesValue))] [CodeGenSerialization(nameof(StopSequences), SerializationValueHook = nameof(SerializeStopSequencesValue), DeserializationValueHook = nameof(DeserializeStopSequencesValue))] [CodeGenSerialization(nameof(LogitBiases), SerializationValueHook = nameof(SerializeLogitBiasesValue), DeserializationValueHook = nameof(DeserializeLogitBiasesValue))] +[CodeGenSerialization(nameof(PredictedContent), SerializationValueHook = nameof(SerializePredictedContentValue), DeserializationValueHook = nameof(DeserializePredictedContentValue))] public partial class ChatCompletionOptions { // CUSTOM: @@ -177,6 +178,13 @@ public ChatCompletionOptions() [CodeGenMember("Store")] public bool? StoredOutputEnabled { get; set; } + /// + /// (o1 and newer reasoning models only) Constrains effort on reasoning for reasoning models. + /// Currently supported values are , , and . + /// Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. + /// + public ChatReasoningEffort? ReasoningEffort { get; set; } + // CUSTOM: Made internal for automatic enablement via audio options. [CodeGenMember("Modalities")] private IList _internalModalities = new ChangeTrackingList(); @@ -196,4 +204,7 @@ public ChatAudioOptions AudioOptions : [InternalCreateChatCompletionRequestModality.Text, InternalCreateChatCompletionRequestModality.Audio]; } } + + [CodeGenMember("Prediction")] + public ChatMessageContent PredictedContent { get; set; } } diff --git a/.dotnet/src/Custom/Chat/ChatMessage.cs b/.dotnet/src/Custom/Chat/ChatMessage.cs index 4e2d91320..011ba8a7e 100644 --- a/.dotnet/src/Custom/Chat/ChatMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatMessage.cs @@ -105,6 +105,17 @@ internal ChatMessage(ChatMessageRole role, string content = null) : this(role) public static SystemChatMessage CreateSystemMessage(params ChatMessageContentPart[] contentParts) => new(contentParts); #endregion + #region DeveloperChatMessage + /// + public static DeveloperChatMessage CreateDeveloperMessage(string content) => new(content); + + /// + public static DeveloperChatMessage CreateDeveloperMessage(IEnumerable contentParts) => new(contentParts); + + /// + public static DeveloperChatMessage CreateDeveloperMessage(params ChatMessageContentPart[] contentParts) => new(contentParts); + #endregion + #region UserChatMessage /// public static UserChatMessage CreateUserMessage(string content) => new(content); diff --git a/.dotnet/src/Custom/Chat/ChatMessageRole.cs b/.dotnet/src/Custom/Chat/ChatMessageRole.cs index 6611ec5d9..83bbba718 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageRole.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageRole.cs @@ -11,6 +11,11 @@ namespace OpenAI.Chat; /// Description /// /// +/// - +/// developer - +/// Instructions to the model that guide the behavior of future assistant messages. Replaces system in o1 and newer models. +/// +/// /// - /// system - /// Instructions to the model that guide the behavior of future assistant messages. @@ -59,6 +64,16 @@ public enum ChatMessageRole [CodeGenMember("System")] System, + /// + /// The developer role, which provides instructions to the model that guide the behavior of future + /// assistant messages + /// + /// + /// developer replaces system when using o1 and newer models. + /// + [CodeGenMember("Developer")] + Developer, + /// /// The user role that provides input from the caller as a prompt for model responses. /// diff --git a/.dotnet/src/Custom/Chat/ChatOutputTokenUsageDetails.cs b/.dotnet/src/Custom/Chat/ChatOutputTokenUsageDetails.cs index cf2be788d..b357a272c 100644 --- a/.dotnet/src/Custom/Chat/ChatOutputTokenUsageDetails.cs +++ b/.dotnet/src/Custom/Chat/ChatOutputTokenUsageDetails.cs @@ -14,4 +14,10 @@ public partial class ChatOutputTokenUsageDetails /// The number of audio tokens in the output. [CodeGenMember("AudioTokens")] public int AudioTokenCount { get; } + + [CodeGenMember("AcceptedPredictionTokens")] + public int PredictionAcceptedTokenCount { get; } + + [CodeGenMember("RejectedPredictionTokens")] + public int PredictionRejectedTokenCount { get; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatReasoningEffort.cs b/.dotnet/src/Custom/Chat/ChatReasoningEffort.cs new file mode 100644 index 000000000..4a6556339 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatReasoningEffort.cs @@ -0,0 +1,9 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Chat; + +[CodeGenModel("CreateChatCompletionRequestReasoningEffort")] +public readonly partial struct ChatReasoningEffort +{} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/DeveloperChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/DeveloperChatMessage.Serialization.cs new file mode 100644 index 000000000..26dadf39e --- /dev/null +++ b/.dotnet/src/Custom/Chat/DeveloperChatMessage.Serialization.cs @@ -0,0 +1,45 @@ +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace OpenAI.Chat; + +[CodeGenSuppress("global::System.ClientModel.Primitives.IJsonModel.Write", typeof(Utf8JsonWriter), typeof(ModelReaderWriterOptions))] +public partial class DeveloperChatMessage : IJsonModel +{ + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + => CustomSerializationHelpers.SerializeInstance(this, SerializeDeveloperChatMessage, writer, options); + + internal static void SerializeDeveloperChatMessage(DeveloperChatMessage instance, Utf8JsonWriter writer, ModelReaderWriterOptions options) + => instance.WriteCore(writer, options); + + internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToSerialString()); + + // Content is required, can be a single string or a collection of ChatMessageContentPart. + if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) + { + writer.WritePropertyName("content"u8); + if (Content.Count == 1 && Content[0].Text != null) + { + writer.WriteStringValue(Content[0].Text); + } + else + { + writer.WriteStartArray(); + foreach (ChatMessageContentPart part in Content) + { + writer.WriteObjectValue(part, options); + } + writer.WriteEndArray(); + } + } + + writer.WriteOptionalProperty("name"u8, ParticipantName, options); + writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); + writer.WriteEndObject(); + } +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/DeveloperChatMessage.cs b/.dotnet/src/Custom/Chat/DeveloperChatMessage.cs new file mode 100644 index 000000000..c24323a13 --- /dev/null +++ b/.dotnet/src/Custom/Chat/DeveloperChatMessage.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; + +namespace OpenAI.Chat; + +/// +/// Represents a chat message of the developer role as supplied to a chat completion request. A developer message is +/// generally supplied as the first message to a chat completion request and guides the model's behavior across future +/// assistant role response messages. These messages may help control behavior, style, tone, and +/// restrictions for a model-based assistant. Developer messages replace system messages for o1 models and newer. +/// +[CodeGenModel("ChatCompletionRequestDeveloperMessage")] +[CodeGenSuppress("DeveloperChatMessage", typeof(ChatMessageContent))] +public partial class DeveloperChatMessage : ChatMessage +{ + /// + /// Creates a new instance of using a collection of content items. + /// For system messages, these can only be of type text. + /// + /// + /// The collection of content items associated with the message. + /// + public DeveloperChatMessage(IEnumerable contentParts) + : base(ChatMessageRole.System, contentParts) + { } + + /// + /// Creates a new instance of using a collection of content items. + /// For system messages, these can only be of type text. + /// + /// + /// The collection of content items associated with the message. + /// + public DeveloperChatMessage(params ChatMessageContentPart[] contentParts) + : base(ChatMessageRole.Developer, contentParts) + { + Argument.AssertNotNullOrEmpty(contentParts, nameof(contentParts)); + } + + /// + /// Creates a new instance of with a single item of text content. + /// + /// The text content of the message. + public DeveloperChatMessage(string content) + : base(ChatMessageRole.Developer, content) + { + Argument.AssertNotNull(content, nameof(content)); + } + + // CUSTOM: Hide the default constructor. + internal DeveloperChatMessage() + { + } + + /// + /// An optional name for the participant. + /// + [CodeGenMember("Name")] + public string ParticipantName { get; set; } +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs index 6a2a78016..4c92c59bd 100644 --- a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs @@ -105,3 +105,8 @@ internal readonly partial struct InternalChatCompletionRequestMessageContentPart [CodeGenModel("ChatCompletionMessageAudioChunk")] internal partial class InternalChatCompletionMessageAudioChunk { } +[CodeGenModel("PredictionContent")] +internal partial class InternalPredictionContent { } + +[CodeGenModel("PredictionContentType")] +internal readonly partial struct InternalPredictionContentType { } diff --git a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs index 3b87a1416..1316c084e 100644 --- a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs +++ b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -116,9 +116,14 @@ public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTok /// Initializes a new instance of . /// A new instance for mocking. - public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default, int audioTokenCount = default) + public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default, int audioTokenCount = default, int predictionAcceptedTokenCount = default, int predictionRejectedTokenCount = 0) { - return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, additionalBinaryDataProperties: null); + return new ChatOutputTokenUsageDetails( + audioTokenCount: audioTokenCount, + reasoningTokenCount: reasoningTokenCount, + predictionAcceptedTokenCount: predictionAcceptedTokenCount, + predictionRejectedTokenCount: predictionRejectedTokenCount, + additionalBinaryDataProperties: null); } public static ChatResponseAudio ChatResponseAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default) diff --git a/.dotnet/src/Custom/Files/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Files/Internal/GeneratorStubs.cs index 7d9c6326b..ea48db3c9 100644 --- a/.dotnet/src/Custom/Files/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Files/Internal/GeneratorStubs.cs @@ -3,9 +3,6 @@ namespace OpenAI.Files; [CodeGenModel("DeleteFileResponseObject")] internal readonly partial struct InternalDeleteFileResponseObject { } -[CodeGenModel("ListFilesResponseObject")] -internal readonly partial struct InternalListFilesResponseObject { } - [CodeGenModel("OpenAIFileObject")] internal readonly partial struct InternalOpenAIFileObject { } diff --git a/.dotnet/src/Custom/Files/OpenAIFileCollection.Serialization.cs b/.dotnet/src/Custom/Files/OpenAIFileCollection.Serialization.cs index 2a498dbe8..d56a22ba8 100644 --- a/.dotnet/src/Custom/Files/OpenAIFileCollection.Serialization.cs +++ b/.dotnet/src/Custom/Files/OpenAIFileCollection.Serialization.cs @@ -40,7 +40,10 @@ internal static OpenAIFileCollection DeserializeOpenAIFileCollection(JsonElement return null; } IReadOnlyList data = default; - InternalListFilesResponseObject @object = default; + string @object = default; + string firstId = default; + string lastId = default; + bool hasMore = false; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -57,7 +60,22 @@ internal static OpenAIFileCollection DeserializeOpenAIFileCollection(JsonElement } if (property.NameEquals("object"u8)) { - @object = new InternalListFilesResponseObject(property.Value.GetString()); + @object = property.Value.GetString(); + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); continue; } if (true) @@ -66,7 +84,7 @@ internal static OpenAIFileCollection DeserializeOpenAIFileCollection(JsonElement } } serializedAdditionalRawData = rawDataDictionary; - return new OpenAIFileCollection(data, @object, serializedAdditionalRawData); + return new OpenAIFileCollection(data, @object, firstId, lastId, hasMore, serializedAdditionalRawData); } } diff --git a/.dotnet/src/Custom/Files/OpenAIFileCollection.cs b/.dotnet/src/Custom/Files/OpenAIFileCollection.cs index 3114ff3b9..e6db62a02 100644 --- a/.dotnet/src/Custom/Files/OpenAIFileCollection.cs +++ b/.dotnet/src/Custom/Files/OpenAIFileCollection.cs @@ -7,31 +7,49 @@ namespace OpenAI.Files; [CodeGenModel("ListFilesResponse")] [CodeGenSuppress("Data")] [CodeGenSuppress(nameof(OpenAIFileCollection))] -[CodeGenSuppress(nameof(OpenAIFileCollection),typeof(InternalListFilesResponseObject), typeof(IDictionary))] +[CodeGenSuppress(nameof(OpenAIFileCollection), typeof(string), typeof(string), typeof(string), typeof(bool))] +[CodeGenSuppress(nameof(OpenAIFileCollection), typeof(string), typeof(string), typeof(string), typeof(bool), typeof(IDictionary))] public partial class OpenAIFileCollection : ReadOnlyCollection { // CUSTOM: Made private. This property does not add value in the context of a strongly-typed class. /// Gets the object. - private InternalListFilesResponseObject Object { get; } = InternalListFilesResponseObject.List; + private string Object { get; } + // CUSTOM: Internalizing pending stanardized pagination representation for the list operation. + [CodeGenMember("FirstId")] + internal string FirstId { get; } + + [CodeGenMember("LastId")] + internal string LastId { get; } + + [CodeGenMember("HasMore")] + internal bool HasMore { get; } + /// Initializes a new instance of . /// /// is null. - internal OpenAIFileCollection(IEnumerable data) + internal OpenAIFileCollection(IEnumerable data, string firstId, string lastId, bool hasMore) : base([.. data]) { + Object = "list"; Argument.AssertNotNull(data, nameof(data)); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; } /// Initializes a new instance of . /// /// /// Keeps track of any properties unknown to the library. - internal OpenAIFileCollection(IReadOnlyList data, InternalListFilesResponseObject @object, IDictionary serializedAdditionalRawData) + internal OpenAIFileCollection(IReadOnlyList data, string @object, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) : base([.. data]) { Object = @object; SerializedAdditionalRawData = serializedAdditionalRawData; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; } /// Initializes a new instance of for deserialization. diff --git a/.dotnet/src/Custom/Files/OpenAIFilesModelFactory.cs b/.dotnet/src/Custom/Files/OpenAIFilesModelFactory.cs index 3dcaafacc..af7e98052 100644 --- a/.dotnet/src/Custom/Files/OpenAIFilesModelFactory.cs +++ b/.dotnet/src/Custom/Files/OpenAIFilesModelFactory.cs @@ -36,13 +36,14 @@ public static OpenAIFile OpenAIFileInfo(string id = null, int? sizeInBytes = nul /// Initializes a new instance of . /// A new instance for mocking. - public static OpenAIFileCollection OpenAIFileCollection(IEnumerable items = null) + public static OpenAIFileCollection OpenAIFileCollection(IEnumerable items = null, string firstId = default, string lastId = default, bool hasMore = default) { items ??= new List(); return new OpenAIFileCollection( items.ToList(), - InternalListFilesResponseObject.List, - serializedAdditionalRawData: null); + firstId, + lastId, + hasMore); } } diff --git a/.dotnet/src/Custom/FineTuning/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/FineTuning/Internal/GeneratorStubs.cs index eb14cf3bd..117370cc5 100644 --- a/.dotnet/src/Custom/FineTuning/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/FineTuning/Internal/GeneratorStubs.cs @@ -136,3 +136,32 @@ internal partial class HyperparameterOptions { } [CodeGenModel("CreateFineTuningJobRequestWandbIntegration")] internal partial class WeightsAndBiasesIntegration { } + +// TODO: not yet integrated + +[CodeGenModel("FineTuneChatRequestInput")] +internal partial class InternalTodoFineTuneChatRequestInput { } + +[CodeGenModel("FineTuneCompletionRequestInput")] +internal partial class InternalTodoFineTuneCompletionRequestInput { } + +[CodeGenModel("FineTuneDPOMethod")] +internal partial class InternalTodoFineTuneDPOMethod { } + +[CodeGenModel("FineTuneDPOMethodHyperparameters")] +internal partial class InternalTodoFineTuneDPOMethodHyperparameters { } + +[CodeGenModel("FineTuneMethod")] +internal partial class InternalTodoFineTuneMethod { } + +[CodeGenModel("FineTuneMethodType")] +internal readonly partial struct InternalTodoFineTuneMethodType { } + +[CodeGenModel("FineTuneSupervisedMethod")] +internal partial class InternalTodoFineTuneSupervisedMethod { } + +[CodeGenModel("FineTuneSupervisedMethodHyperparameters")] +internal partial class InternalFineTuneSupervisedMethodHyperparameters { } + +[CodeGenModel("FineTuningJobEventType")] +internal readonly partial struct InternalFineTuningJobEventType { } \ No newline at end of file diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationIncompleteReason.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationIncompleteReason.cs new file mode 100644 index 000000000..bb2b76df0 --- /dev/null +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationIncompleteReason.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.RealtimeConversation; + +[Experimental("OPENAI002")] +[CodeGenModel("RealtimeResponseStatusDetailsReason")] +public readonly partial struct ConversationIncompleteReason +{ +} \ No newline at end of file diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationInputTokenUsageDetails.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationInputTokenUsageDetails.cs new file mode 100644 index 000000000..713ca5b8d --- /dev/null +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationInputTokenUsageDetails.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.RealtimeConversation; + +[Experimental("OPENAI002")] +[CodeGenModel("RealtimeResponseUsageInputTokenDetails")] +public partial class ConversationInputTokenUsageDetails +{ + // CUSTOM: Remove output model optionality, make 'Count' names consistent with Chat + + [CodeGenMember("AudioTokens")] + public int AudioTokenCount { get; } + + [CodeGenMember("CachedTokens")] + public int CachedTokenCount { get; } + + [CodeGenMember("TextTokens")] + public int TextTokenCount { get; } +} diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationOutputTokenUsageDetails.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationOutputTokenUsageDetails.cs new file mode 100644 index 000000000..ba1c36561 --- /dev/null +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationOutputTokenUsageDetails.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.RealtimeConversation; + +[Experimental("OPENAI002")] +[CodeGenModel("RealtimeResponseUsageOutputTokenDetails")] +public partial class ConversationOutputTokenUsageDetails +{ + // CUSTOM: Remove output model optionality, make 'Count' names consistent with Chat + + [CodeGenMember("TextTokens")] + public int TextTokenCount { get; } + + [CodeGenMember("AudioTokens")] + public int AudioTokenCount { get; } +} diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationResponseOptions.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationResponseOptions.cs new file mode 100644 index 000000000..6060d1721 --- /dev/null +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationResponseOptions.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ClientModel.Primitives; +using System.Text.Json; +using System.Diagnostics.CodeAnalysis; +using System.Linq; + +namespace OpenAI.RealtimeConversation; + +[Experimental("OPENAI002")] +[CodeGenModel("RealtimeResponseCreateParams")] +public partial class ConversationResponseOptions +{ + [CodeGenMember("Conversation")] + public ResponseConversationSelection? ConversationSelection { get; set; } + + [CodeGenMember("Modalities")] + private IList _internalModalities; + + public ConversationContentModalities ContentModalities + { + get => ConversationContentModalitiesExtensions.FromInternalModalities(_internalModalities); + set => _internalModalities = value.ToInternalModalities(); + } + + [CodeGenMember("ToolChoice")] + private BinaryData _internalToolChoice; + + public ConversationToolChoice ToolChoice + { + get => ConversationToolChoice.FromBinaryData(_internalToolChoice); + set + { + _internalToolChoice = value is not null + ? ModelReaderWriter.Write(value) + : null; + } + } + + [CodeGenMember("MaxResponseOutputTokens")] + private BinaryData _maxResponseOutputTokens; + + public ConversationMaxTokensChoice MaxOutputTokens + { + get => ConversationMaxTokensChoice.FromBinaryData(_maxResponseOutputTokens); + set + { + _maxResponseOutputTokens = value == null ? null : ModelReaderWriter.Write(value); + } + } + + [CodeGenMember("Input")] + public IList OverrideItems { get; } +} diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationSessionOptions.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationSessionOptions.cs index 14f2abeb1..5a0bd2be2 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ConversationSessionOptions.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationSessionOptions.cs @@ -9,6 +9,9 @@ namespace OpenAI.RealtimeConversation; [CodeGenModel("RealtimeRequestSession")] public partial class ConversationSessionOptions { + [CodeGenMember("Model")] + internal InternalRealtimeRequestSessionModel? Model { get; set; } + [CodeGenMember("Modalities")] private IList _internalModalities; diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationStatusDetails.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationStatusDetails.cs index fc4a7f94e..8cf1826f8 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ConversationStatusDetails.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationStatusDetails.cs @@ -8,6 +8,16 @@ namespace OpenAI.RealtimeConversation; [CodeGenModel("RealtimeResponseStatusDetails")] public partial class ConversationStatusDetails { - [CodeGenMember("Kind")] + [CodeGenMember("Type")] public ConversationStatus StatusKind { get; } + + [CodeGenMember("Reason")] + public ConversationIncompleteReason? IncompleteReason { get; } + + public string ErrorType => Error?.Type ?? string.Empty; + + public string ErrorCode => Error?.Code ?? string.Empty; + + [CodeGenMember("Error")] + internal InternalRealtimeResponseStatusDetailsError Error { get; set; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/RealtimeConversation/GeneratorStubs.cs b/.dotnet/src/Custom/RealtimeConversation/GeneratorStubs.cs index e5594d79e..3e3cfce8e 100644 --- a/.dotnet/src/Custom/RealtimeConversation/GeneratorStubs.cs +++ b/.dotnet/src/Custom/RealtimeConversation/GeneratorStubs.cs @@ -9,7 +9,5 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")][CodeGenModel("RealtimeMessageRole")] public readonly partial struct ConversationMessageRole { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseStatus")] public readonly partial struct ConversationStatus { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseUsage")] public partial class ConversationTokenUsage { } -[Experimental("OPENAI002")][CodeGenModel("RealtimeResponseUsageInputTokenDetails")] public partial class ConversationInputTokenUsageDetails { } -[Experimental("OPENAI002")][CodeGenModel("RealtimeResponseUsageOutputTokenDetails")] public partial class ConversationOutputTokenUsageDetails { } [Experimental("OPENAI002")][CodeGenModel("RealtimeToolType")] public readonly partial struct ConversationToolKind { } [Experimental("OPENAI002")][CodeGenModel("RealtimeVoice")] public readonly partial struct ConversationVoice { } diff --git a/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs index 3b1c192ec..10c06a468 100644 --- a/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs @@ -14,17 +14,20 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")][CodeGenModel("RealtimeClientEventType")] internal readonly partial struct InternalRealtimeClientEventType { } [Experimental("OPENAI002")][CodeGenModel("RealtimeConversationResponseItemObject")] internal readonly partial struct InternalRealtimeConversationResponseItemObject { } [Experimental("OPENAI002")][CodeGenModel("RealtimeItemType")] internal readonly partial struct InternalRealtimeItemType { } +[Experimental("OPENAI002")][CodeGenModel("RealtimeModality")] internal readonly partial struct InternalRealtimeRequestSessionModality { } [Experimental("OPENAI002")][CodeGenModel("RealtimeRequestAudioContentPart")] internal partial class InternalRealtimeRequestAudioContentPart { } [Experimental("OPENAI002")][CodeGenModel("RealtimeRequestFunctionCallItem")] internal partial class InternalRealtimeRequestFunctionCallItem { } [Experimental("OPENAI002")][CodeGenModel("RealtimeRequestFunctionCallOutputItem")] internal partial class InternalRealtimeRequestFunctionCallOutputItem { } [Experimental("OPENAI002")][CodeGenModel("RealtimeRequestMessageItem")] internal partial class InternalRealtimeRequestMessageItem { } -[Experimental("OPENAI002")][CodeGenModel("RealtimeRequestSessionModality")] internal readonly partial struct InternalRealtimeRequestSessionModality { } +[Experimental("OPENAI002")][CodeGenModel("RealtimeRequestSessionModel")] internal readonly partial struct InternalRealtimeRequestSessionModel { } [Experimental("OPENAI002")][CodeGenModel("RealtimeRequestTextContentPart")] internal partial class InternalRealtimeRequestTextContentPart { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseAudioContentPart")] internal partial class InternalRealtimeResponseAudioContentPart { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseFunctionCallItem")] internal partial class InternalRealtimeResponseFunctionCallItem { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseFunctionCallOutputItem")] internal partial class InternalRealtimeResponseFunctionCallOutputItem { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseObject")] internal readonly partial struct InternalRealtimeResponseObject { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseSessionObject")] internal readonly partial struct InternalRealtimeResponseSessionObject { } +[Experimental("OPENAI002")][CodeGenModel("RealtimeResponseStatusDetailsError")] internal partial class InternalRealtimeResponseStatusDetailsError { } +[Experimental("OPENAI002")][CodeGenModel("RealtimeResponseStatusDetailsType")] internal readonly partial struct InternalRealtimeResponseStatusDetailsType { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseTextContentPart")] internal partial class InternalRealtimeResponseTextContentPart { } [Experimental("OPENAI002")][CodeGenModel("RealtimeServerEventConversationCreated")] internal partial class InternalRealtimeServerEventConversationCreated { } [Experimental("OPENAI002")][CodeGenModel("RealtimeServerEventConversationCreatedConversation")] internal partial class InternalRealtimeServerEventConversationCreatedConversation { } @@ -36,9 +39,8 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeClientEvent")] internal partial class UnknownRealtimeClientEvent { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeContentPart")] internal partial class UnknownRealtimeContentPart { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeConversationRequestItem")] internal partial class UnknownRealtimeRequestItem { } -[Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeRequestMessageItem")] internal partial class UnknownRealtimeRequestMessageItem { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeConversationResponseItem")] internal partial class UnknownRealtimeResponseItem { } -[Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeResponseStatusDetails")] internal partial class UnknownRealtimeResponseStatusDetails { } +[Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeRequestMessageItem")] internal partial class UnknownRealtimeRequestMessageItem { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeServerEvent")] internal partial class UnknownRealtimeServerEvent { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeTool")] internal partial class UnknownRealtimeTool { } [Experimental("OPENAI002")][CodeGenModel("UnknownRealtimeToolChoiceObject")] internal partial class UnknownRealtimeToolChoiceObject { } diff --git a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeClientEventResponseCreateResponse.cs b/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeClientEventResponseCreateResponse.cs deleted file mode 100644 index e6e6112f5..000000000 --- a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeClientEventResponseCreateResponse.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ClientModel.Primitives; -using System.Text.Json; -using System.Diagnostics.CodeAnalysis; -using System.Linq; - -namespace OpenAI.RealtimeConversation; - -[Experimental("OPENAI002")] -[CodeGenModel("RealtimeResponseOptions")] -internal partial class InternalRealtimeResponseOptions -{ - [CodeGenMember("ToolChoice")] - public BinaryData ToolChoice { get; set; } - - public static InternalRealtimeResponseOptions FromSessionOptions( - ConversationSessionOptions sessionOptions) - { - Argument.AssertNotNull(sessionOptions, nameof(sessionOptions)); - if (Optional.IsDefined(sessionOptions.InputAudioFormat)) - { - throw new InvalidOperationException($"{nameof(sessionOptions.InputAudioFormat)} cannot be overriden" - + " per response."); - } - BinaryData maxTokensChoice = Optional.IsDefined(sessionOptions.MaxOutputTokens) - ? ModelReaderWriter.Write(sessionOptions.MaxOutputTokens) - : null; - IList internalModalities - = sessionOptions.ContentModalities.ToInternalModalities(); - BinaryData toolChoice = Optional.IsDefined(sessionOptions.ToolChoice) - ? ModelReaderWriter.Write(sessionOptions.ToolChoice) - : null; - InternalRealtimeResponseOptions internalOptions = new( - modalities: internalModalities, - instructions: sessionOptions.Instructions, - voice: sessionOptions.Voice, - outputAudioFormat: sessionOptions.OutputAudioFormat, - tools: sessionOptions.Tools, - toolChoice: toolChoice, - temperature: sessionOptions.Temperature, - maxOutputTokens: maxTokensChoice, - additionalBinaryDataProperties: null); - return internalOptions; - } -} diff --git a/.dotnet/src/Custom/RealtimeConversation/RealtimeConversationSession.cs b/.dotnet/src/Custom/RealtimeConversation/RealtimeConversationSession.cs index 07f375398..31a4ef50a 100644 --- a/.dotnet/src/Custom/RealtimeConversation/RealtimeConversationSession.cs +++ b/.dotnet/src/Custom/RealtimeConversation/RealtimeConversationSession.cs @@ -276,36 +276,33 @@ public virtual void InterruptResponse(CancellationToken cancellationToken = defa SendCommand(internalCommand, cancellationToken); } - public virtual async Task StartResponseAsync(CancellationToken cancellationToken = default) + public virtual async Task StartResponseAsync(ConversationResponseOptions options, CancellationToken cancellationToken = default) { - InternalRealtimeResponseOptions internalOptions = new(); - InternalRealtimeClientEventResponseCreate internalCommand = new(internalOptions); + InternalRealtimeClientEventResponseCreate internalCommand = new( + kind: InternalRealtimeClientEventType.ResponseCreate, + eventId: null, + additionalBinaryDataProperties: null, + response: options); await SendCommandAsync(internalCommand, cancellationToken).ConfigureAwait(false); } - - public virtual void StartResponse(CancellationToken cancellationToken = default) + public virtual async Task StartResponseAsync(CancellationToken cancellationToken = default) { - InternalRealtimeResponseOptions internalOptions = new(); - InternalRealtimeClientEventResponseCreate internalCommand = new(internalOptions); - SendCommand(internalCommand, cancellationToken); + await StartResponseAsync(new ConversationResponseOptions(), cancellationToken).ConfigureAwait(false); } - public virtual async Task StartResponseAsync(ConversationSessionOptions sessionOptionOverrides, CancellationToken cancellationToken = default) + public virtual void StartResponse(ConversationResponseOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(sessionOptionOverrides, nameof(sessionOptionOverrides)); - InternalRealtimeResponseOptions internalOptions - = InternalRealtimeResponseOptions.FromSessionOptions(sessionOptionOverrides); - InternalRealtimeClientEventResponseCreate internalCommand = new(internalOptions); - await SendCommandAsync(internalCommand, cancellationToken).ConfigureAwait(false); + InternalRealtimeClientEventResponseCreate internalCommand = new( + kind: InternalRealtimeClientEventType.ResponseCreate, + eventId: null, + additionalBinaryDataProperties: null, + response: options); + SendCommand(internalCommand, cancellationToken); } - public virtual void StartResponse(ConversationSessionOptions sessionOptionOverrides, CancellationToken cancellationToken = default) + public void StartResponse(CancellationToken cancellationToken = default) { - Argument.AssertNotNull(sessionOptionOverrides, nameof(sessionOptionOverrides)); - InternalRealtimeResponseOptions internalOptions - = InternalRealtimeResponseOptions.FromSessionOptions(sessionOptionOverrides); - InternalRealtimeClientEventResponseCreate internalCommand = new(internalOptions); - SendCommand(internalCommand, cancellationToken); + StartResponse(new ConversationResponseOptions(), cancellationToken); } public virtual async Task CancelResponseAsync(CancellationToken cancellationToken = default) diff --git a/.dotnet/src/Custom/RealtimeConversation/ResponseConversationSelection.cs b/.dotnet/src/Custom/RealtimeConversation/ResponseConversationSelection.cs new file mode 100644 index 000000000..b2f77da72 --- /dev/null +++ b/.dotnet/src/Custom/RealtimeConversation/ResponseConversationSelection.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.ClientModel.Primitives; +using System.Text.Json; +using System.Diagnostics.CodeAnalysis; +using System.Linq; + +namespace OpenAI.RealtimeConversation; + +[Experimental("OPENAI002")] +[CodeGenModel("RealtimeResponseCreateParamsConversation")] +public readonly partial struct ResponseConversationSelection +{ +} diff --git a/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationResponseStartedUpdate.cs b/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationResponseStartedUpdate.cs index b0bb3a136..43ba27e8c 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationResponseStartedUpdate.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ResponseUpdates/ConversationResponseStartedUpdate.cs @@ -19,7 +19,7 @@ public partial class ConversationResponseStartedUpdate public string ResponseId => _internalResponse.Id; - public ConversationStatus Status => _internalResponse.Status; + public ConversationStatus Status => _internalResponse.Status.Value; public ConversationStatusDetails StatusDetails => _internalResponse.StatusDetails; diff --git a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs index 42cdea309..b137e7f49 100644 --- a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs @@ -285,6 +285,23 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteNull("store"u8); } } + if (Optional.IsDefined(ReasoningEffort) && _additionalBinaryDataProperties?.ContainsKey("reasoning_effort") != true) + { + writer.WritePropertyName("reasoning_effort"u8); + writer.WriteStringValue(ReasoningEffort.Value.ToString()); + } + if (Optional.IsDefined(PredictedContent) && _additionalBinaryDataProperties?.ContainsKey("prediction") != true) + { + if (PredictedContent != null) + { + writer.WritePropertyName("prediction"u8); + this.SerializePredictedContentValue(writer, options); + } + else + { + writer.WriteNull("prediction"u8); + } + } if (Optional.IsDefined(_serviceTier) && _additionalBinaryDataProperties?.ContainsKey("service_tier") != true) { if (_serviceTier != null) @@ -391,6 +408,8 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme IList functions = default; IDictionary metadata = default; bool? storedOutputEnabled = default; + ChatReasoningEffort? reasoningEffort = default; + ChatMessageContent predictedContent = default; InternalCreateChatCompletionRequestServiceTier? serviceTier = default; IList internalModalities = default; ChatAudioOptions audioOptions = default; @@ -642,6 +661,20 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme storedOutputEnabled = prop.Value.GetBoolean(); continue; } + if (prop.NameEquals("reasoning_effort"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + reasoningEffort = new ChatReasoningEffort(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("prediction"u8)) + { + DeserializePredictedContentValue(prop, ref predictedContent); + continue; + } if (prop.NameEquals("service_tier"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) @@ -707,6 +740,8 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme functions ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), storedOutputEnabled, + reasoningEffort, + predictedContent, serviceTier, internalModalities, audioOptions, diff --git a/.dotnet/src/Generated/Models/ChatCompletionOptions.cs b/.dotnet/src/Generated/Models/ChatCompletionOptions.cs index b5e6dfe2b..8718d1892 100644 --- a/.dotnet/src/Generated/Models/ChatCompletionOptions.cs +++ b/.dotnet/src/Generated/Models/ChatCompletionOptions.cs @@ -11,7 +11,7 @@ public partial class ChatCompletionOptions { private protected IDictionary _additionalBinaryDataProperties; - internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, ChatResponseFormat responseFormat, float? temperature, float? topP, IList tools, IList messages, InternalCreateChatCompletionRequestModel model, int? n, bool? stream, InternalChatCompletionStreamOptions streamOptions, bool? includeLogProbabilities, int? topLogProbabilityCount, IList stopSequences, IDictionary logitBiases, ChatToolChoice toolChoice, ChatFunctionChoice functionChoice, bool? allowParallelToolCalls, string endUserId, long? seed, int? deprecatedMaxTokens, int? maxOutputTokenCount, IList functions, IDictionary metadata, bool? storedOutputEnabled, InternalCreateChatCompletionRequestServiceTier? serviceTier, IList internalModalities, ChatAudioOptions audioOptions, IDictionary additionalBinaryDataProperties) + internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, ChatResponseFormat responseFormat, float? temperature, float? topP, IList tools, IList messages, InternalCreateChatCompletionRequestModel model, int? n, bool? stream, InternalChatCompletionStreamOptions streamOptions, bool? includeLogProbabilities, int? topLogProbabilityCount, IList stopSequences, IDictionary logitBiases, ChatToolChoice toolChoice, ChatFunctionChoice functionChoice, bool? allowParallelToolCalls, string endUserId, long? seed, int? deprecatedMaxTokens, int? maxOutputTokenCount, IList functions, IDictionary metadata, bool? storedOutputEnabled, ChatReasoningEffort? reasoningEffort, ChatMessageContent predictedContent, InternalCreateChatCompletionRequestServiceTier? serviceTier, IList internalModalities, ChatAudioOptions audioOptions, IDictionary additionalBinaryDataProperties) { FrequencyPenalty = frequencyPenalty; PresencePenalty = presencePenalty; @@ -38,6 +38,8 @@ internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, Functions = functions; Metadata = metadata; StoredOutputEnabled = storedOutputEnabled; + ReasoningEffort = reasoningEffort; + PredictedContent = predictedContent; _serviceTier = serviceTier; _internalModalities = internalModalities; _audioOptions = audioOptions; diff --git a/.dotnet/src/Generated/Models/ChatInputTokenUsageDetails.Serialization.cs b/.dotnet/src/Generated/Models/ChatInputTokenUsageDetails.Serialization.cs index 0fac3b930..8b5fb999d 100644 --- a/.dotnet/src/Generated/Models/ChatInputTokenUsageDetails.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatInputTokenUsageDetails.Serialization.cs @@ -13,10 +13,6 @@ namespace OpenAI.Chat { public partial class ChatInputTokenUsageDetails : IJsonModel { - internal ChatInputTokenUsageDetails() - { - } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -88,11 +84,19 @@ internal static ChatInputTokenUsageDetails DeserializeChatInputTokenUsageDetails { if (prop.NameEquals("audio_tokens"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } audioTokenCount = prop.Value.GetInt32(); continue; } if (prop.NameEquals("cached_tokens"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } cachedTokenCount = prop.Value.GetInt32(); continue; } diff --git a/.dotnet/src/Generated/Models/ChatInputTokenUsageDetails.cs b/.dotnet/src/Generated/Models/ChatInputTokenUsageDetails.cs index 3fc955b5f..1b1db2e20 100644 --- a/.dotnet/src/Generated/Models/ChatInputTokenUsageDetails.cs +++ b/.dotnet/src/Generated/Models/ChatInputTokenUsageDetails.cs @@ -11,10 +11,8 @@ public partial class ChatInputTokenUsageDetails { private protected IDictionary _additionalBinaryDataProperties; - internal ChatInputTokenUsageDetails(int audioTokenCount, int cachedTokenCount) + internal ChatInputTokenUsageDetails() { - AudioTokenCount = audioTokenCount; - CachedTokenCount = cachedTokenCount; } internal ChatInputTokenUsageDetails(int audioTokenCount, int cachedTokenCount, IDictionary additionalBinaryDataProperties) diff --git a/.dotnet/src/Generated/Models/ChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/ChatMessage.Serialization.cs index 0f27516c0..3b134ad8b 100644 --- a/.dotnet/src/Generated/Models/ChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatMessage.Serialization.cs @@ -77,6 +77,8 @@ internal static ChatMessage DeserializeChatMessage(JsonElement element, ModelRea { case "system": return SystemChatMessage.DeserializeSystemChatMessage(element, options); + case "developer": + return DeveloperChatMessage.DeserializeDeveloperChatMessage(element, options); case "user": return UserChatMessage.DeserializeUserChatMessage(element, options); case "assistant": diff --git a/.dotnet/src/Generated/Models/ChatMessageRole.Serialization.cs b/.dotnet/src/Generated/Models/ChatMessageRole.Serialization.cs index 55d2b2eaf..2063ddd7d 100644 --- a/.dotnet/src/Generated/Models/ChatMessageRole.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatMessageRole.Serialization.cs @@ -11,6 +11,7 @@ internal static partial class ChatMessageRoleExtensions public static string ToSerialString(this Chat.ChatMessageRole value) => value switch { Chat.ChatMessageRole.System => "system", + Chat.ChatMessageRole.Developer => "developer", Chat.ChatMessageRole.User => "user", Chat.ChatMessageRole.Assistant => "assistant", Chat.ChatMessageRole.Tool => "tool", @@ -24,6 +25,10 @@ public static Chat.ChatMessageRole ToChatMessageRole(this string value) { return Chat.ChatMessageRole.System; } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "developer")) + { + return Chat.ChatMessageRole.Developer; + } if (StringComparer.OrdinalIgnoreCase.Equals(value, "user")) { return Chat.ChatMessageRole.User; diff --git a/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs b/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs index f6c672ead..c714cd457 100644 --- a/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs @@ -13,10 +13,6 @@ namespace OpenAI.Chat { public partial class ChatOutputTokenUsageDetails : IJsonModel { - internal ChatOutputTokenUsageDetails() - { - } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -41,6 +37,16 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("audio_tokens"u8); writer.WriteNumberValue(AudioTokenCount); } + if (_additionalBinaryDataProperties?.ContainsKey("accepted_prediction_tokens") != true) + { + writer.WritePropertyName("accepted_prediction_tokens"u8); + writer.WriteNumberValue(PredictionAcceptedTokenCount); + } + if (_additionalBinaryDataProperties?.ContainsKey("rejected_prediction_tokens") != true) + { + writer.WritePropertyName("rejected_prediction_tokens"u8); + writer.WriteNumberValue(PredictionRejectedTokenCount); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -83,25 +89,53 @@ internal static ChatOutputTokenUsageDetails DeserializeChatOutputTokenUsageDetai } int reasoningTokenCount = default; int audioTokenCount = default; + int predictionAcceptedTokenCount = default; + int predictionRejectedTokenCount = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("reasoning_tokens"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } reasoningTokenCount = prop.Value.GetInt32(); continue; } if (prop.NameEquals("audio_tokens"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } audioTokenCount = prop.Value.GetInt32(); continue; } + if (prop.NameEquals("accepted_prediction_tokens"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + predictionAcceptedTokenCount = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("rejected_prediction_tokens"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + predictionRejectedTokenCount = prop.Value.GetInt32(); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, additionalBinaryDataProperties); + return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, predictionAcceptedTokenCount, predictionRejectedTokenCount, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.cs b/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.cs index d6a3d4687..93ea0dba5 100644 --- a/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.cs +++ b/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.cs @@ -11,16 +11,16 @@ public partial class ChatOutputTokenUsageDetails { private protected IDictionary _additionalBinaryDataProperties; - internal ChatOutputTokenUsageDetails(int reasoningTokenCount, int audioTokenCount) + internal ChatOutputTokenUsageDetails() { - ReasoningTokenCount = reasoningTokenCount; - AudioTokenCount = audioTokenCount; } - internal ChatOutputTokenUsageDetails(int reasoningTokenCount, int audioTokenCount, IDictionary additionalBinaryDataProperties) + internal ChatOutputTokenUsageDetails(int reasoningTokenCount, int audioTokenCount, int predictionAcceptedTokenCount, int predictionRejectedTokenCount, IDictionary additionalBinaryDataProperties) { ReasoningTokenCount = reasoningTokenCount; AudioTokenCount = audioTokenCount; + PredictionAcceptedTokenCount = predictionAcceptedTokenCount; + PredictionRejectedTokenCount = predictionRejectedTokenCount; _additionalBinaryDataProperties = additionalBinaryDataProperties; } diff --git a/.dotnet/src/Generated/Models/ChatReasoningEffort.cs b/.dotnet/src/Generated/Models/ChatReasoningEffort.cs new file mode 100644 index 000000000..a4b79fce4 --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatReasoningEffort.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + public readonly partial struct ChatReasoningEffort : IEquatable + { + private readonly string _value; + private const string LowValue = "low"; + private const string MediumValue = "medium"; + private const string HighValue = "high"; + + public ChatReasoningEffort(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static ChatReasoningEffort Low { get; } = new ChatReasoningEffort(LowValue); + + public static ChatReasoningEffort Medium { get; } = new ChatReasoningEffort(MediumValue); + + public static ChatReasoningEffort High { get; } = new ChatReasoningEffort(HighValue); + + public static bool operator ==(ChatReasoningEffort left, ChatReasoningEffort right) => left.Equals(right); + + public static bool operator !=(ChatReasoningEffort left, ChatReasoningEffort right) => !left.Equals(right); + + public static implicit operator ChatReasoningEffort(string value) => new ChatReasoningEffort(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatReasoningEffort other && Equals(other); + + public bool Equals(ChatReasoningEffort other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/ChatResponseVoice.cs b/.dotnet/src/Generated/Models/ChatResponseVoice.cs index d294da7cb..bc6b1fd39 100644 --- a/.dotnet/src/Generated/Models/ChatResponseVoice.cs +++ b/.dotnet/src/Generated/Models/ChatResponseVoice.cs @@ -12,11 +12,13 @@ namespace OpenAI.Chat { private readonly string _value; private const string AlloyValue = "alloy"; + private const string AshValue = "ash"; + private const string BalladValue = "ballad"; + private const string CoralValue = "coral"; private const string EchoValue = "echo"; - private const string FableValue = "fable"; - private const string OnyxValue = "onyx"; - private const string NovaValue = "nova"; + private const string SageValue = "sage"; private const string ShimmerValue = "shimmer"; + private const string VerseValue = "verse"; public ChatResponseVoice(string value) { @@ -27,16 +29,20 @@ public ChatResponseVoice(string value) public static ChatResponseVoice Alloy { get; } = new ChatResponseVoice(AlloyValue); - public static ChatResponseVoice Echo { get; } = new ChatResponseVoice(EchoValue); + public static ChatResponseVoice Ash { get; } = new ChatResponseVoice(AshValue); + + public static ChatResponseVoice Ballad { get; } = new ChatResponseVoice(BalladValue); - public static ChatResponseVoice Fable { get; } = new ChatResponseVoice(FableValue); + public static ChatResponseVoice Coral { get; } = new ChatResponseVoice(CoralValue); - public static ChatResponseVoice Onyx { get; } = new ChatResponseVoice(OnyxValue); + public static ChatResponseVoice Echo { get; } = new ChatResponseVoice(EchoValue); - public static ChatResponseVoice Nova { get; } = new ChatResponseVoice(NovaValue); + public static ChatResponseVoice Sage { get; } = new ChatResponseVoice(SageValue); public static ChatResponseVoice Shimmer { get; } = new ChatResponseVoice(ShimmerValue); + public static ChatResponseVoice Verse { get; } = new ChatResponseVoice(VerseValue); + public static bool operator ==(ChatResponseVoice left, ChatResponseVoice right) => left.Equals(right); public static bool operator !=(ChatResponseVoice left, ChatResponseVoice right) => !left.Equals(right); diff --git a/.dotnet/src/Generated/Models/ConversationIncompleteReason.cs b/.dotnet/src/Generated/Models/ConversationIncompleteReason.cs new file mode 100644 index 000000000..16e7c9a93 --- /dev/null +++ b/.dotnet/src/Generated/Models/ConversationIncompleteReason.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + public readonly partial struct ConversationIncompleteReason : IEquatable + { + private readonly string _value; + private const string TurnDetectedValue = "turn_detected"; + private const string ClientCancelledValue = "client_cancelled"; + private const string MaxOutputTokensValue = "max_output_tokens"; + private const string ContentFilterValue = "content_filter"; + + public ConversationIncompleteReason(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static ConversationIncompleteReason TurnDetected { get; } = new ConversationIncompleteReason(TurnDetectedValue); + + public static ConversationIncompleteReason ClientCancelled { get; } = new ConversationIncompleteReason(ClientCancelledValue); + + public static ConversationIncompleteReason MaxOutputTokens { get; } = new ConversationIncompleteReason(MaxOutputTokensValue); + + public static ConversationIncompleteReason ContentFilter { get; } = new ConversationIncompleteReason(ContentFilterValue); + + public static bool operator ==(ConversationIncompleteReason left, ConversationIncompleteReason right) => left.Equals(right); + + public static bool operator !=(ConversationIncompleteReason left, ConversationIncompleteReason right) => !left.Equals(right); + + public static implicit operator ConversationIncompleteReason(string value) => new ConversationIncompleteReason(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ConversationIncompleteReason other && Equals(other); + + public bool Equals(ConversationIncompleteReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/ConversationInputTokenUsageDetails.Serialization.cs b/.dotnet/src/Generated/Models/ConversationInputTokenUsageDetails.Serialization.cs index ca18ed51e..f5902b67d 100644 --- a/.dotnet/src/Generated/Models/ConversationInputTokenUsageDetails.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationInputTokenUsageDetails.Serialization.cs @@ -13,10 +13,6 @@ namespace OpenAI.RealtimeConversation { public partial class ConversationInputTokenUsageDetails : IJsonModel { - internal ConversationInputTokenUsageDetails() - { - } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,20 +27,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(ConversationInputTokenUsageDetails)} does not support writing '{format}' format."); } + if (_additionalBinaryDataProperties?.ContainsKey("audio_tokens") != true) + { + writer.WritePropertyName("audio_tokens"u8); + writer.WriteNumberValue(AudioTokenCount); + } if (_additionalBinaryDataProperties?.ContainsKey("cached_tokens") != true) { writer.WritePropertyName("cached_tokens"u8); - writer.WriteNumberValue(CachedTokens); + writer.WriteNumberValue(CachedTokenCount); } if (_additionalBinaryDataProperties?.ContainsKey("text_tokens") != true) { writer.WritePropertyName("text_tokens"u8); - writer.WriteNumberValue(TextTokens); - } - if (_additionalBinaryDataProperties?.ContainsKey("audio_tokens") != true) - { - writer.WritePropertyName("audio_tokens"u8); - writer.WriteNumberValue(AudioTokens); + writer.WriteNumberValue(TextTokenCount); } if (true && _additionalBinaryDataProperties != null) { @@ -86,25 +82,37 @@ internal static ConversationInputTokenUsageDetails DeserializeConversationInputT { return null; } - int cachedTokens = default; - int textTokens = default; - int audioTokens = default; + int audioTokenCount = default; + int cachedTokenCount = default; + int textTokenCount = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("cached_tokens"u8)) + if (prop.NameEquals("audio_tokens"u8)) { - cachedTokens = prop.Value.GetInt32(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + audioTokenCount = prop.Value.GetInt32(); continue; } - if (prop.NameEquals("text_tokens"u8)) + if (prop.NameEquals("cached_tokens"u8)) { - textTokens = prop.Value.GetInt32(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cachedTokenCount = prop.Value.GetInt32(); continue; } - if (prop.NameEquals("audio_tokens"u8)) + if (prop.NameEquals("text_tokens"u8)) { - audioTokens = prop.Value.GetInt32(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + textTokenCount = prop.Value.GetInt32(); continue; } if (true) @@ -112,7 +120,7 @@ internal static ConversationInputTokenUsageDetails DeserializeConversationInputT additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ConversationInputTokenUsageDetails(cachedTokens, textTokens, audioTokens, additionalBinaryDataProperties); + return new ConversationInputTokenUsageDetails(audioTokenCount, cachedTokenCount, textTokenCount, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/ConversationInputTokenUsageDetails.cs b/.dotnet/src/Generated/Models/ConversationInputTokenUsageDetails.cs index d22b0020a..277871f66 100644 --- a/.dotnet/src/Generated/Models/ConversationInputTokenUsageDetails.cs +++ b/.dotnet/src/Generated/Models/ConversationInputTokenUsageDetails.cs @@ -11,27 +11,18 @@ public partial class ConversationInputTokenUsageDetails { private protected IDictionary _additionalBinaryDataProperties; - internal ConversationInputTokenUsageDetails(int cachedTokens, int textTokens, int audioTokens) + internal ConversationInputTokenUsageDetails() { - CachedTokens = cachedTokens; - TextTokens = textTokens; - AudioTokens = audioTokens; } - internal ConversationInputTokenUsageDetails(int cachedTokens, int textTokens, int audioTokens, IDictionary additionalBinaryDataProperties) + internal ConversationInputTokenUsageDetails(int audioTokenCount, int cachedTokenCount, int textTokenCount, IDictionary additionalBinaryDataProperties) { - CachedTokens = cachedTokens; - TextTokens = textTokens; - AudioTokens = audioTokens; + AudioTokenCount = audioTokenCount; + CachedTokenCount = cachedTokenCount; + TextTokenCount = textTokenCount; _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public int CachedTokens { get; } - - public int TextTokens { get; } - - public int AudioTokens { get; } - internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/ConversationOutputTokenUsageDetails.Serialization.cs b/.dotnet/src/Generated/Models/ConversationOutputTokenUsageDetails.Serialization.cs index 35403bdb8..9661ae7f7 100644 --- a/.dotnet/src/Generated/Models/ConversationOutputTokenUsageDetails.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationOutputTokenUsageDetails.Serialization.cs @@ -13,10 +13,6 @@ namespace OpenAI.RealtimeConversation { public partial class ConversationOutputTokenUsageDetails : IJsonModel { - internal ConversationOutputTokenUsageDetails() - { - } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -34,12 +30,12 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("text_tokens") != true) { writer.WritePropertyName("text_tokens"u8); - writer.WriteNumberValue(TextTokens); + writer.WriteNumberValue(TextTokenCount); } if (_additionalBinaryDataProperties?.ContainsKey("audio_tokens") != true) { writer.WritePropertyName("audio_tokens"u8); - writer.WriteNumberValue(AudioTokens); + writer.WriteNumberValue(AudioTokenCount); } if (true && _additionalBinaryDataProperties != null) { @@ -81,19 +77,27 @@ internal static ConversationOutputTokenUsageDetails DeserializeConversationOutpu { return null; } - int textTokens = default; - int audioTokens = default; + int textTokenCount = default; + int audioTokenCount = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("text_tokens"u8)) { - textTokens = prop.Value.GetInt32(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + textTokenCount = prop.Value.GetInt32(); continue; } if (prop.NameEquals("audio_tokens"u8)) { - audioTokens = prop.Value.GetInt32(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + audioTokenCount = prop.Value.GetInt32(); continue; } if (true) @@ -101,7 +105,7 @@ internal static ConversationOutputTokenUsageDetails DeserializeConversationOutpu additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ConversationOutputTokenUsageDetails(textTokens, audioTokens, additionalBinaryDataProperties); + return new ConversationOutputTokenUsageDetails(textTokenCount, audioTokenCount, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/ConversationOutputTokenUsageDetails.cs b/.dotnet/src/Generated/Models/ConversationOutputTokenUsageDetails.cs index 0a424eadc..0fa593dc2 100644 --- a/.dotnet/src/Generated/Models/ConversationOutputTokenUsageDetails.cs +++ b/.dotnet/src/Generated/Models/ConversationOutputTokenUsageDetails.cs @@ -11,23 +11,17 @@ public partial class ConversationOutputTokenUsageDetails { private protected IDictionary _additionalBinaryDataProperties; - internal ConversationOutputTokenUsageDetails(int textTokens, int audioTokens) + internal ConversationOutputTokenUsageDetails() { - TextTokens = textTokens; - AudioTokens = audioTokens; } - internal ConversationOutputTokenUsageDetails(int textTokens, int audioTokens, IDictionary additionalBinaryDataProperties) + internal ConversationOutputTokenUsageDetails(int textTokenCount, int audioTokenCount, IDictionary additionalBinaryDataProperties) { - TextTokens = textTokens; - AudioTokens = audioTokens; + TextTokenCount = textTokenCount; + AudioTokenCount = audioTokenCount; _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public int TextTokens { get; } - - public int AudioTokens { get; } - internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseOptions.Serialization.cs b/.dotnet/src/Generated/Models/ConversationResponseOptions.Serialization.cs similarity index 52% rename from .dotnet/src/Generated/Models/InternalRealtimeResponseOptions.Serialization.cs rename to .dotnet/src/Generated/Models/ConversationResponseOptions.Serialization.cs index 7689a5e57..48aee4803 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationResponseOptions.Serialization.cs @@ -11,9 +11,9 @@ namespace OpenAI.RealtimeConversation { - internal partial class InternalRealtimeResponseOptions : IJsonModel + public partial class ConversationResponseOptions : IJsonModel { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -22,20 +22,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalRealtimeResponseOptions)} does not support writing '{format}' format."); - } - if (Optional.IsCollectionDefined(Modalities) && _additionalBinaryDataProperties?.ContainsKey("modalities") != true) - { - writer.WritePropertyName("modalities"u8); - writer.WriteStartArray(); - foreach (InternalRealtimeRequestSessionModality item in Modalities) - { - writer.WriteStringValue(item.ToString()); - } - writer.WriteEndArray(); + throw new FormatException($"The model {nameof(ConversationResponseOptions)} does not support writing '{format}' format."); } if (Optional.IsDefined(Instructions) && _additionalBinaryDataProperties?.ContainsKey("instructions") != true) { @@ -67,25 +57,73 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("temperature"u8); writer.WriteNumberValue(Temperature.Value); } - if (Optional.IsDefined(MaxOutputTokens) && _additionalBinaryDataProperties?.ContainsKey("max_output_tokens") != true) + if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"u8); + } + } + if (Optional.IsDefined(ConversationSelection) && _additionalBinaryDataProperties?.ContainsKey("conversation") != true) + { + writer.WritePropertyName("conversation"u8); + writer.WriteStringValue(ConversationSelection.Value.ToString()); + } + if (Optional.IsCollectionDefined(OverrideItems) && _additionalBinaryDataProperties?.ContainsKey("input") != true) + { + writer.WritePropertyName("input"u8); + writer.WriteStartArray(); + foreach (ConversationItem item in OverrideItems) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(_internalModalities) && _additionalBinaryDataProperties?.ContainsKey("modalities") != true) + { + writer.WritePropertyName("modalities"u8); + writer.WriteStartArray(); + foreach (InternalRealtimeRequestSessionModality item in _internalModalities) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(_internalToolChoice) && _additionalBinaryDataProperties?.ContainsKey("tool_choice") != true) { - writer.WritePropertyName("max_output_tokens"u8); + writer.WritePropertyName("tool_choice"u8); #if NET6_0_OR_GREATER - writer.WriteRawValue(MaxOutputTokens); + writer.WriteRawValue(_internalToolChoice); #else - using (JsonDocument document = JsonDocument.Parse(MaxOutputTokens)) + using (JsonDocument document = JsonDocument.Parse(_internalToolChoice)) { JsonSerializer.Serialize(writer, document.RootElement); } #endif } - if (Optional.IsDefined(ToolChoice) && _additionalBinaryDataProperties?.ContainsKey("tool_choice") != true) + if (Optional.IsDefined(_maxResponseOutputTokens) && _additionalBinaryDataProperties?.ContainsKey("max_response_output_tokens") != true) { - writer.WritePropertyName("tool_choice"u8); + writer.WritePropertyName("max_response_output_tokens"u8); #if NET6_0_OR_GREATER - writer.WriteRawValue(ToolChoice); + writer.WriteRawValue(_maxResponseOutputTokens); #else - using (JsonDocument document = JsonDocument.Parse(ToolChoice)) + using (JsonDocument document = JsonDocument.Parse(_maxResponseOutputTokens)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -112,50 +150,39 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalRealtimeResponseOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + ConversationResponseOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual InternalRealtimeResponseOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual ConversationResponseOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalRealtimeResponseOptions)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(ConversationResponseOptions)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRealtimeResponseOptions(document.RootElement, options); + return DeserializeConversationResponseOptions(document.RootElement, options); } - internal static InternalRealtimeResponseOptions DeserializeInternalRealtimeResponseOptions(JsonElement element, ModelReaderWriterOptions options) + internal static ConversationResponseOptions DeserializeConversationResponseOptions(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } - IList modalities = default; string instructions = default; ConversationVoice? voice = default; ConversationAudioFormat? outputAudioFormat = default; IList tools = default; float? temperature = default; - BinaryData maxOutputTokens = default; - BinaryData toolChoice = default; + IDictionary metadata = default; + ResponseConversationSelection? conversationSelection = default; + IList overrideItems = default; + IList internalModalities = default; + BinaryData internalToolChoice = default; + BinaryData maxResponseOutputTokens = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("modalities"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in prop.Value.EnumerateArray()) - { - array.Add(new InternalRealtimeRequestSessionModality(item.GetString())); - } - modalities = array; - continue; - } if (prop.NameEquals("instructions"u8)) { instructions = prop.Value.GetString(); @@ -202,13 +229,62 @@ internal static InternalRealtimeResponseOptions DeserializeInternalRealtimeRespo temperature = prop.Value.GetSingle(); continue; } - if (prop.NameEquals("max_output_tokens"u8)) + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("conversation"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maxOutputTokens = BinaryData.FromString(prop.Value.GetRawText()); + conversationSelection = new ResponseConversationSelection(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("input"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ConversationItem.DeserializeConversationItem(item, options)); + } + overrideItems = array; + continue; + } + if (prop.NameEquals("modalities"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new InternalRealtimeRequestSessionModality(item.GetString())); + } + internalModalities = array; continue; } if (prop.NameEquals("tool_choice"u8)) @@ -217,7 +293,16 @@ internal static InternalRealtimeResponseOptions DeserializeInternalRealtimeRespo { continue; } - toolChoice = BinaryData.FromString(prop.Value.GetRawText()); + internalToolChoice = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("max_response_output_tokens"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxResponseOutputTokens = BinaryData.FromString(prop.Value.GetRawText()); continue; } if (true) @@ -225,65 +310,68 @@ internal static InternalRealtimeResponseOptions DeserializeInternalRealtimeRespo additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRealtimeResponseOptions( - modalities ?? new ChangeTrackingList(), + return new ConversationResponseOptions( instructions, voice, outputAudioFormat, tools ?? new ChangeTrackingList(), temperature, - maxOutputTokens, - toolChoice, + metadata ?? new ChangeTrackingDictionary(), + conversationSelection, + overrideItems ?? new ChangeTrackingList(), + internalModalities, + internalToolChoice, + maxResponseOutputTokens, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalRealtimeResponseOptions)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(ConversationResponseOptions)} does not support writing '{options.Format}' format."); } } - InternalRealtimeResponseOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + ConversationResponseOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual InternalRealtimeResponseOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual ConversationResponseOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalRealtimeResponseOptions(document.RootElement, options); + return DeserializeConversationResponseOptions(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalRealtimeResponseOptions)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(ConversationResponseOptions)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalRealtimeResponseOptions internalRealtimeResponseOptions) + public static implicit operator BinaryContent(ConversationResponseOptions conversationResponseOptions) { - if (internalRealtimeResponseOptions == null) + if (conversationResponseOptions == null) { return null; } - return BinaryContent.Create(internalRealtimeResponseOptions, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(conversationResponseOptions, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalRealtimeResponseOptions(ClientResult result) + public static explicit operator ConversationResponseOptions(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalRealtimeResponseOptions(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeConversationResponseOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/ConversationResponseOptions.cs b/.dotnet/src/Generated/Models/ConversationResponseOptions.cs new file mode 100644 index 000000000..1249e3656 --- /dev/null +++ b/.dotnet/src/Generated/Models/ConversationResponseOptions.cs @@ -0,0 +1,57 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + public partial class ConversationResponseOptions + { + private protected IDictionary _additionalBinaryDataProperties; + + public ConversationResponseOptions() + { + Tools = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + OverrideItems = new ChangeTrackingList(); + _internalModalities = new ChangeTrackingList(); + } + + internal ConversationResponseOptions(string instructions, ConversationVoice? voice, ConversationAudioFormat? outputAudioFormat, IList tools, float? temperature, IDictionary metadata, ResponseConversationSelection? conversationSelection, IList overrideItems, IList internalModalities, BinaryData internalToolChoice, BinaryData maxResponseOutputTokens, IDictionary additionalBinaryDataProperties) + { + Instructions = instructions; + Voice = voice; + OutputAudioFormat = outputAudioFormat; + Tools = tools; + Temperature = temperature; + Metadata = metadata; + ConversationSelection = conversationSelection; + OverrideItems = overrideItems; + _internalModalities = internalModalities; + _internalToolChoice = internalToolChoice; + _maxResponseOutputTokens = maxResponseOutputTokens; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public string Instructions { get; set; } + + public ConversationVoice? Voice { get; set; } + + public ConversationAudioFormat? OutputAudioFormat { get; set; } + + public IList Tools { get; } + + public float? Temperature { get; set; } + + public IDictionary Metadata { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/ConversationSessionOptions.Serialization.cs b/.dotnet/src/Generated/Models/ConversationSessionOptions.Serialization.cs index 4a25c88a8..b02b97b35 100644 --- a/.dotnet/src/Generated/Models/ConversationSessionOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationSessionOptions.Serialization.cs @@ -62,6 +62,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("temperature"u8); writer.WriteNumberValue(Temperature.Value); } + if (Optional.IsDefined(Model) && _additionalBinaryDataProperties?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.Value.ToString()); + } if (Optional.IsDefined(TurnDetectionOptions) && _additionalBinaryDataProperties?.ContainsKey("turn_detection") != true) { if (TurnDetectionOptions != null) @@ -166,6 +171,7 @@ internal static ConversationSessionOptions DeserializeConversationSessionOptions ConversationAudioFormat? outputAudioFormat = default; IList tools = default; float? temperature = default; + InternalRealtimeRequestSessionModel? model = default; ConversationTurnDetectionOptions turnDetectionOptions = default; ConversationInputTranscriptionOptions inputTranscriptionOptions = default; IList internalModalities = default; @@ -229,6 +235,15 @@ internal static ConversationSessionOptions DeserializeConversationSessionOptions temperature = prop.Value.GetSingle(); continue; } + if (prop.NameEquals("model"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = new InternalRealtimeRequestSessionModel(prop.Value.GetString()); + continue; + } if (prop.NameEquals("turn_detection"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) @@ -293,6 +308,7 @@ internal static ConversationSessionOptions DeserializeConversationSessionOptions outputAudioFormat, tools ?? new ChangeTrackingList(), temperature, + model, turnDetectionOptions, inputTranscriptionOptions, internalModalities, diff --git a/.dotnet/src/Generated/Models/ConversationSessionOptions.cs b/.dotnet/src/Generated/Models/ConversationSessionOptions.cs index 7cf4e0ef0..7bdfebf04 100644 --- a/.dotnet/src/Generated/Models/ConversationSessionOptions.cs +++ b/.dotnet/src/Generated/Models/ConversationSessionOptions.cs @@ -18,7 +18,7 @@ public ConversationSessionOptions() _internalModalities = new ChangeTrackingList(); } - internal ConversationSessionOptions(string instructions, ConversationVoice? voice, ConversationAudioFormat? inputAudioFormat, ConversationAudioFormat? outputAudioFormat, IList tools, float? temperature, ConversationTurnDetectionOptions turnDetectionOptions, ConversationInputTranscriptionOptions inputTranscriptionOptions, IList internalModalities, BinaryData internalToolChoice, BinaryData maxResponseOutputTokens, IDictionary additionalBinaryDataProperties) + internal ConversationSessionOptions(string instructions, ConversationVoice? voice, ConversationAudioFormat? inputAudioFormat, ConversationAudioFormat? outputAudioFormat, IList tools, float? temperature, InternalRealtimeRequestSessionModel? model, ConversationTurnDetectionOptions turnDetectionOptions, ConversationInputTranscriptionOptions inputTranscriptionOptions, IList internalModalities, BinaryData internalToolChoice, BinaryData maxResponseOutputTokens, IDictionary additionalBinaryDataProperties) { Instructions = instructions; Voice = voice; @@ -26,6 +26,7 @@ internal ConversationSessionOptions(string instructions, ConversationVoice? voic OutputAudioFormat = outputAudioFormat; Tools = tools; Temperature = temperature; + Model = model; TurnDetectionOptions = turnDetectionOptions; InputTranscriptionOptions = inputTranscriptionOptions; _internalModalities = internalModalities; diff --git a/.dotnet/src/Generated/Models/ConversationStatus.cs b/.dotnet/src/Generated/Models/ConversationStatus.cs index d08d9ebbc..23700eb55 100644 --- a/.dotnet/src/Generated/Models/ConversationStatus.cs +++ b/.dotnet/src/Generated/Models/ConversationStatus.cs @@ -11,11 +11,10 @@ namespace OpenAI.RealtimeConversation public readonly partial struct ConversationStatus : IEquatable { private readonly string _value; - private const string InProgressValue = "in_progress"; private const string CompletedValue = "completed"; private const string CancelledValue = "cancelled"; - private const string IncompleteValue = "incomplete"; private const string FailedValue = "failed"; + private const string IncompleteValue = "incomplete"; public ConversationStatus(string value) { @@ -24,16 +23,14 @@ public ConversationStatus(string value) _value = value; } - public static ConversationStatus InProgress { get; } = new ConversationStatus(InProgressValue); - public static ConversationStatus Completed { get; } = new ConversationStatus(CompletedValue); public static ConversationStatus Cancelled { get; } = new ConversationStatus(CancelledValue); - public static ConversationStatus Incomplete { get; } = new ConversationStatus(IncompleteValue); - public static ConversationStatus Failed { get; } = new ConversationStatus(FailedValue); + public static ConversationStatus Incomplete { get; } = new ConversationStatus(IncompleteValue); + public static bool operator ==(ConversationStatus left, ConversationStatus right) => left.Equals(right); public static bool operator !=(ConversationStatus left, ConversationStatus right) => !left.Equals(right); diff --git a/.dotnet/src/Generated/Models/ConversationStatusDetails.Serialization.cs b/.dotnet/src/Generated/Models/ConversationStatusDetails.Serialization.cs index 7aabd5019..7a9aaff72 100644 --- a/.dotnet/src/Generated/Models/ConversationStatusDetails.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationStatusDetails.Serialization.cs @@ -5,18 +5,14 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using OpenAI; namespace OpenAI.RealtimeConversation { - [PersistableModelProxy(typeof(UnknownRealtimeResponseStatusDetails))] - public abstract partial class ConversationStatusDetails : IJsonModel + public partial class ConversationStatusDetails : IJsonModel { - internal ConversationStatusDetails() - { - } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -36,6 +32,16 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("type"u8); writer.WriteStringValue(StatusKind.ToString()); } + if (Optional.IsDefined(IncompleteReason) && _additionalBinaryDataProperties?.ContainsKey("reason") != true) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(IncompleteReason.Value.ToString()); + } + if (Optional.IsDefined(Error) && _additionalBinaryDataProperties?.ContainsKey("error") != true) + { + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(Error, options); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -76,7 +82,45 @@ internal static ConversationStatusDetails DeserializeConversationStatusDetails(J { return null; } - return UnknownRealtimeResponseStatusDetails.DeserializeUnknownRealtimeResponseStatusDetails(element, options); + ConversationStatus statusKind = default; + ConversationIncompleteReason? incompleteReason = default; + InternalRealtimeResponseStatusDetailsError error = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + statusKind = new ConversationStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("reason"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + incompleteReason = new ConversationIncompleteReason(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = InternalRealtimeResponseStatusDetailsError.DeserializeInternalRealtimeResponseStatusDetailsError(prop.Value, options); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ConversationStatusDetails(statusKind, incompleteReason, error, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/ConversationStatusDetails.cs b/.dotnet/src/Generated/Models/ConversationStatusDetails.cs index 1b560fe8d..53a06b7f0 100644 --- a/.dotnet/src/Generated/Models/ConversationStatusDetails.cs +++ b/.dotnet/src/Generated/Models/ConversationStatusDetails.cs @@ -7,18 +7,19 @@ namespace OpenAI.RealtimeConversation { - public abstract partial class ConversationStatusDetails + public partial class ConversationStatusDetails { private protected IDictionary _additionalBinaryDataProperties; - private protected ConversationStatusDetails(ConversationStatus statusKind) + internal ConversationStatusDetails() { - StatusKind = statusKind; } - internal ConversationStatusDetails(ConversationStatus statusKind, IDictionary additionalBinaryDataProperties) + internal ConversationStatusDetails(ConversationStatus statusKind, ConversationIncompleteReason? incompleteReason, InternalRealtimeResponseStatusDetailsError error, IDictionary additionalBinaryDataProperties) { StatusKind = statusKind; + IncompleteReason = incompleteReason; + Error = error; _additionalBinaryDataProperties = additionalBinaryDataProperties; } diff --git a/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs b/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs index 04a8e335f..c1525aa87 100644 --- a/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs @@ -13,10 +13,6 @@ namespace OpenAI.RealtimeConversation { public partial class ConversationTokenUsage : IJsonModel { - internal ConversationTokenUsage() - { - } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,27 +27,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(ConversationTokenUsage)} does not support writing '{format}' format."); } - if (_additionalBinaryDataProperties?.ContainsKey("total_tokens") != true) + if (Optional.IsDefined(TotalTokens) && _additionalBinaryDataProperties?.ContainsKey("total_tokens") != true) { writer.WritePropertyName("total_tokens"u8); - writer.WriteNumberValue(TotalTokens); + writer.WriteNumberValue(TotalTokens.Value); } - if (_additionalBinaryDataProperties?.ContainsKey("input_tokens") != true) + if (Optional.IsDefined(InputTokens) && _additionalBinaryDataProperties?.ContainsKey("input_tokens") != true) { writer.WritePropertyName("input_tokens"u8); - writer.WriteNumberValue(InputTokens); + writer.WriteNumberValue(InputTokens.Value); } - if (_additionalBinaryDataProperties?.ContainsKey("output_tokens") != true) + if (Optional.IsDefined(OutputTokens) && _additionalBinaryDataProperties?.ContainsKey("output_tokens") != true) { writer.WritePropertyName("output_tokens"u8); - writer.WriteNumberValue(OutputTokens); + writer.WriteNumberValue(OutputTokens.Value); } - if (_additionalBinaryDataProperties?.ContainsKey("input_token_details") != true) + if (Optional.IsDefined(InputTokenDetails) && _additionalBinaryDataProperties?.ContainsKey("input_token_details") != true) { writer.WritePropertyName("input_token_details"u8); writer.WriteObjectValue(InputTokenDetails, options); } - if (_additionalBinaryDataProperties?.ContainsKey("output_token_details") != true) + if (Optional.IsDefined(OutputTokenDetails) && _additionalBinaryDataProperties?.ContainsKey("output_token_details") != true) { writer.WritePropertyName("output_token_details"u8); writer.WriteObjectValue(OutputTokenDetails, options); @@ -96,9 +92,9 @@ internal static ConversationTokenUsage DeserializeConversationTokenUsage(JsonEle { return null; } - int totalTokens = default; - int inputTokens = default; - int outputTokens = default; + int? totalTokens = default; + int? inputTokens = default; + int? outputTokens = default; ConversationInputTokenUsageDetails inputTokenDetails = default; ConversationOutputTokenUsageDetails outputTokenDetails = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); @@ -106,26 +102,46 @@ internal static ConversationTokenUsage DeserializeConversationTokenUsage(JsonEle { if (prop.NameEquals("total_tokens"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } totalTokens = prop.Value.GetInt32(); continue; } if (prop.NameEquals("input_tokens"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } inputTokens = prop.Value.GetInt32(); continue; } if (prop.NameEquals("output_tokens"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } outputTokens = prop.Value.GetInt32(); continue; } if (prop.NameEquals("input_token_details"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } inputTokenDetails = ConversationInputTokenUsageDetails.DeserializeConversationInputTokenUsageDetails(prop.Value, options); continue; } if (prop.NameEquals("output_token_details"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } outputTokenDetails = ConversationOutputTokenUsageDetails.DeserializeConversationOutputTokenUsageDetails(prop.Value, options); continue; } diff --git a/.dotnet/src/Generated/Models/ConversationTokenUsage.cs b/.dotnet/src/Generated/Models/ConversationTokenUsage.cs index edc12d4e9..fdeb570ae 100644 --- a/.dotnet/src/Generated/Models/ConversationTokenUsage.cs +++ b/.dotnet/src/Generated/Models/ConversationTokenUsage.cs @@ -11,16 +11,11 @@ public partial class ConversationTokenUsage { private protected IDictionary _additionalBinaryDataProperties; - internal ConversationTokenUsage(int totalTokens, int inputTokens, int outputTokens, ConversationInputTokenUsageDetails inputTokenDetails, ConversationOutputTokenUsageDetails outputTokenDetails) + internal ConversationTokenUsage() { - TotalTokens = totalTokens; - InputTokens = inputTokens; - OutputTokens = outputTokens; - InputTokenDetails = inputTokenDetails; - OutputTokenDetails = outputTokenDetails; } - internal ConversationTokenUsage(int totalTokens, int inputTokens, int outputTokens, ConversationInputTokenUsageDetails inputTokenDetails, ConversationOutputTokenUsageDetails outputTokenDetails, IDictionary additionalBinaryDataProperties) + internal ConversationTokenUsage(int? totalTokens, int? inputTokens, int? outputTokens, ConversationInputTokenUsageDetails inputTokenDetails, ConversationOutputTokenUsageDetails outputTokenDetails, IDictionary additionalBinaryDataProperties) { TotalTokens = totalTokens; InputTokens = inputTokens; @@ -30,11 +25,11 @@ internal ConversationTokenUsage(int totalTokens, int inputTokens, int outputToke _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public int TotalTokens { get; } + public int? TotalTokens { get; } - public int InputTokens { get; } + public int? InputTokens { get; } - public int OutputTokens { get; } + public int? OutputTokens { get; } public ConversationInputTokenUsageDetails InputTokenDetails { get; } diff --git a/.dotnet/src/Generated/Models/ConversationVoice.cs b/.dotnet/src/Generated/Models/ConversationVoice.cs index 20419d714..5ee367c7c 100644 --- a/.dotnet/src/Generated/Models/ConversationVoice.cs +++ b/.dotnet/src/Generated/Models/ConversationVoice.cs @@ -12,8 +12,13 @@ namespace OpenAI.RealtimeConversation { private readonly string _value; private const string AlloyValue = "alloy"; - private const string ShimmerValue = "shimmer"; + private const string AshValue = "ash"; + private const string BalladValue = "ballad"; + private const string CoralValue = "coral"; private const string EchoValue = "echo"; + private const string SageValue = "sage"; + private const string ShimmerValue = "shimmer"; + private const string VerseValue = "verse"; public ConversationVoice(string value) { @@ -24,10 +29,20 @@ public ConversationVoice(string value) public static ConversationVoice Alloy { get; } = new ConversationVoice(AlloyValue); - public static ConversationVoice Shimmer { get; } = new ConversationVoice(ShimmerValue); + public static ConversationVoice Ash { get; } = new ConversationVoice(AshValue); + + public static ConversationVoice Ballad { get; } = new ConversationVoice(BalladValue); + + public static ConversationVoice Coral { get; } = new ConversationVoice(CoralValue); public static ConversationVoice Echo { get; } = new ConversationVoice(EchoValue); + public static ConversationVoice Sage { get; } = new ConversationVoice(SageValue); + + public static ConversationVoice Shimmer { get; } = new ConversationVoice(ShimmerValue); + + public static ConversationVoice Verse { get; } = new ConversationVoice(VerseValue); + public static bool operator ==(ConversationVoice left, ConversationVoice right) => left.Equals(right); public static bool operator !=(ConversationVoice left, ConversationVoice right) => !left.Equals(right); diff --git a/.dotnet/src/Generated/Models/DeveloperChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/DeveloperChatMessage.Serialization.cs new file mode 100644 index 000000000..9fa960482 --- /dev/null +++ b/.dotnet/src/Generated/Models/DeveloperChatMessage.Serialization.cs @@ -0,0 +1,128 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + public partial class DeveloperChatMessage : IJsonModel + { + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeveloperChatMessage)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(ParticipantName) && _additionalBinaryDataProperties?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(ParticipantName); + } + } + + DeveloperChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DeveloperChatMessage)JsonModelCreateCore(ref reader, options); + + protected override ChatMessage JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeveloperChatMessage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeveloperChatMessage(document.RootElement, options); + } + + internal static DeveloperChatMessage DeserializeDeveloperChatMessage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ChatMessageContent content = default; + Chat.ChatMessageRole role = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string participantName = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("content"u8)) + { + DeserializeContentValue(prop, ref content); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = prop.Value.GetString().ToChatMessageRole(); + continue; + } + if (prop.NameEquals("name"u8)) + { + participantName = prop.Value.GetString(); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DeveloperChatMessage(content, role, additionalBinaryDataProperties, participantName); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DeveloperChatMessage)} does not support writing '{options.Format}' format."); + } + } + + DeveloperChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DeveloperChatMessage)PersistableModelCreateCore(data, options); + + protected override ChatMessage PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeDeveloperChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeveloperChatMessage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(DeveloperChatMessage developerChatMessage) + { + if (developerChatMessage == null) + { + return null; + } + return BinaryContent.Create(developerChatMessage, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator DeveloperChatMessage(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeDeveloperChatMessage(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/DeveloperChatMessage.cs b/.dotnet/src/Generated/Models/DeveloperChatMessage.cs new file mode 100644 index 000000000..b391b2890 --- /dev/null +++ b/.dotnet/src/Generated/Models/DeveloperChatMessage.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Chat +{ + public partial class DeveloperChatMessage : ChatMessage + { + internal DeveloperChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string participantName) : base(content, role, additionalBinaryDataProperties) + { + ParticipantName = participantName; + } + } +} diff --git a/.dotnet/src/Generated/Models/FineTuningJob.Serialization.cs b/.dotnet/src/Generated/Models/FineTuningJob.Serialization.cs index 68aff9421..69d786bfa 100644 --- a/.dotnet/src/Generated/Models/FineTuningJob.Serialization.cs +++ b/.dotnet/src/Generated/Models/FineTuningJob.Serialization.cs @@ -192,6 +192,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteNull("estimatedFinish"u8); } } + if (Optional.IsDefined(Method) && _additionalBinaryDataProperties?.ContainsKey("method") != true) + { + writer.WritePropertyName("method"u8); + writer.WriteObjectValue(Method, options); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -250,6 +255,7 @@ internal static FineTuningJob DeserializeFineTuningJob(JsonElement element, Mode IList integrations = default; int seed = default; DateTimeOffset? estimatedFinish = default; + InternalTodoFineTuneMethod @method = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -399,6 +405,15 @@ internal static FineTuningJob DeserializeFineTuningJob(JsonElement element, Mode estimatedFinish = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); continue; } + if (prop.NameEquals("method"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @method = InternalTodoFineTuneMethod.DeserializeInternalTodoFineTuneMethod(prop.Value, options); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -423,6 +438,7 @@ internal static FineTuningJob DeserializeFineTuningJob(JsonElement element, Mode integrations ?? new ChangeTrackingList(), seed, estimatedFinish, + @method, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/FineTuningJob.cs b/.dotnet/src/Generated/Models/FineTuningJob.cs index cd8649531..7c29b6d61 100644 --- a/.dotnet/src/Generated/Models/FineTuningJob.cs +++ b/.dotnet/src/Generated/Models/FineTuningJob.cs @@ -32,7 +32,7 @@ internal FineTuningJob(string id, DateTimeOffset createdAt, FineTuningJobError e Seed = seed; } - internal FineTuningJob(string userProvidedSuffix, string id, DateTimeOffset createdAt, FineTuningJobError error, string fineTunedModel, DateTimeOffset? finishedAt, FineTuningJobHyperparameters hyperparameters, string model, InternalFineTuningJobObject @object, string organizationId, IList resultFiles, FineTuningJobStatus status, int? trainedTokens, string trainingFile, string validationFile, IList integrations, int seed, DateTimeOffset? estimatedFinish, IDictionary additionalBinaryDataProperties) + internal FineTuningJob(string userProvidedSuffix, string id, DateTimeOffset createdAt, FineTuningJobError error, string fineTunedModel, DateTimeOffset? finishedAt, FineTuningJobHyperparameters hyperparameters, string model, InternalFineTuningJobObject @object, string organizationId, IList resultFiles, FineTuningJobStatus status, int? trainedTokens, string trainingFile, string validationFile, IList integrations, int seed, DateTimeOffset? estimatedFinish, InternalTodoFineTuneMethod @method, IDictionary additionalBinaryDataProperties) { UserProvidedSuffix = userProvidedSuffix; Id = id; @@ -52,6 +52,7 @@ internal FineTuningJob(string userProvidedSuffix, string id, DateTimeOffset crea Integrations = integrations; Seed = seed; EstimatedFinish = estimatedFinish; + Method = @method; _additionalBinaryDataProperties = additionalBinaryDataProperties; } @@ -91,6 +92,8 @@ internal FineTuningJob(string userProvidedSuffix, string id, DateTimeOffset crea public DateTimeOffset? EstimatedFinish { get; } + public InternalTodoFineTuneMethod Method { get; } + internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/FineTuningJobEvent.Serialization.cs b/.dotnet/src/Generated/Models/FineTuningJobEvent.Serialization.cs index 2c3beecb5..ea048b303 100644 --- a/.dotnet/src/Generated/Models/FineTuningJobEvent.Serialization.cs +++ b/.dotnet/src/Generated/Models/FineTuningJobEvent.Serialization.cs @@ -31,6 +31,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(FineTuningJobEvent)} does not support writing '{format}' format."); } + if (_additionalBinaryDataProperties?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } if (_additionalBinaryDataProperties?.ContainsKey("id") != true) { writer.WritePropertyName("id"u8); @@ -51,10 +56,22 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("message"u8); writer.WriteStringValue(Message); } - if (_additionalBinaryDataProperties?.ContainsKey("object") != true) + if (Optional.IsDefined(Type) && _additionalBinaryDataProperties?.ContainsKey("type") != true) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsDefined(Data) && _additionalBinaryDataProperties?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Data); +#else + using (JsonDocument document = JsonDocument.Parse(Data)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif } if (true && _additionalBinaryDataProperties != null) { @@ -96,14 +113,21 @@ internal static FineTuningJobEvent DeserializeFineTuningJobEvent(JsonElement ele { return null; } + InternalFineTuningJobEventObject @object = default; string id = default; DateTimeOffset createdAt = default; FineTuning.FineTuningJobEventLevel level = default; string message = default; - InternalFineTuningJobEventObject @object = default; + InternalFineTuningJobEventType? @type = default; + BinaryData data = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { + if (prop.NameEquals("object"u8)) + { + @object = new InternalFineTuningJobEventObject(prop.Value.GetString()); + continue; + } if (prop.NameEquals("id"u8)) { id = prop.Value.GetString(); @@ -124,9 +148,22 @@ internal static FineTuningJobEvent DeserializeFineTuningJobEvent(JsonElement ele message = prop.Value.GetString(); continue; } - if (prop.NameEquals("object"u8)) + if (prop.NameEquals("type"u8)) { - @object = new InternalFineTuningJobEventObject(prop.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @type = new InternalFineTuningJobEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("data"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + data = BinaryData.FromString(prop.Value.GetRawText()); continue; } if (true) @@ -135,11 +172,13 @@ internal static FineTuningJobEvent DeserializeFineTuningJobEvent(JsonElement ele } } return new FineTuningJobEvent( + @object, id, createdAt, level, message, - @object, + @type, + data, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/FineTuningJobEvent.cs b/.dotnet/src/Generated/Models/FineTuningJobEvent.cs index 223fb4005..0830a329d 100644 --- a/.dotnet/src/Generated/Models/FineTuningJobEvent.cs +++ b/.dotnet/src/Generated/Models/FineTuningJobEvent.cs @@ -19,16 +19,20 @@ internal FineTuningJobEvent(string id, DateTimeOffset createdAt, FineTuning.Fine Message = message; } - internal FineTuningJobEvent(string id, DateTimeOffset createdAt, FineTuning.FineTuningJobEventLevel level, string message, InternalFineTuningJobEventObject @object, IDictionary additionalBinaryDataProperties) + internal FineTuningJobEvent(InternalFineTuningJobEventObject @object, string id, DateTimeOffset createdAt, FineTuning.FineTuningJobEventLevel level, string message, InternalFineTuningJobEventType? @type, BinaryData data, IDictionary additionalBinaryDataProperties) { + Object = @object; Id = id; CreatedAt = createdAt; Level = level; Message = message; - Object = @object; + Type = @type; + Data = data; _additionalBinaryDataProperties = additionalBinaryDataProperties; } + public InternalFineTuningJobEventObject Object { get; } = "fine_tuning.job.event"; + public string Id { get; } public DateTimeOffset CreatedAt { get; } @@ -37,7 +41,9 @@ internal FineTuningJobEvent(string id, DateTimeOffset createdAt, FineTuning.Fine public string Message { get; } - public InternalFineTuningJobEventObject Object { get; } = "fine_tuning.job.event"; + public InternalFineTuningJobEventType? Type { get; } + + public BinaryData Data { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/FineTuningJobHyperparameters.Serialization.cs b/.dotnet/src/Generated/Models/FineTuningJobHyperparameters.Serialization.cs index abe7ba36f..4b059813b 100644 --- a/.dotnet/src/Generated/Models/FineTuningJobHyperparameters.Serialization.cs +++ b/.dotnet/src/Generated/Models/FineTuningJobHyperparameters.Serialization.cs @@ -31,7 +31,7 @@ private void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions { throw new FormatException($"The model {nameof(FineTuningJobHyperparameters)} does not support writing '{format}' format."); } - if (_additionalBinaryDataProperties?.ContainsKey("n_epochs") != true) + if (Optional.IsDefined(NEpochs) && _additionalBinaryDataProperties?.ContainsKey("n_epochs") != true) { writer.WritePropertyName("n_epochs"u8); #if NET6_0_OR_GREATER @@ -43,7 +43,7 @@ private void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions } #endif } - if (_additionalBinaryDataProperties?.ContainsKey("batch_size") != true) + if (Optional.IsDefined(BatchSize) && _additionalBinaryDataProperties?.ContainsKey("batch_size") != true) { writer.WritePropertyName("batch_size"u8); #if NET6_0_OR_GREATER @@ -55,7 +55,7 @@ private void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions } #endif } - if (_additionalBinaryDataProperties?.ContainsKey("learning_rate_multiplier") != true) + if (Optional.IsDefined(LearningRateMultiplier) && _additionalBinaryDataProperties?.ContainsKey("learning_rate_multiplier") != true) { writer.WritePropertyName("learning_rate_multiplier"u8); #if NET6_0_OR_GREATER @@ -115,16 +115,28 @@ internal static FineTuningJobHyperparameters DeserializeFineTuningJobHyperparame { if (prop.NameEquals("n_epochs"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } nEpochs = BinaryData.FromString(prop.Value.GetRawText()); continue; } if (prop.NameEquals("batch_size"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } batchSize = BinaryData.FromString(prop.Value.GetRawText()); continue; } if (prop.NameEquals("learning_rate_multiplier"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } learningRateMultiplier = BinaryData.FromString(prop.Value.GetRawText()); continue; } diff --git a/.dotnet/src/Generated/Models/FineTuningJobHyperparametersBatchSizeChoiceEnum.cs b/.dotnet/src/Generated/Models/FineTuningJobHyperparametersBatchSizeChoiceEnum.cs deleted file mode 100644 index e5ad18b8d..000000000 --- a/.dotnet/src/Generated/Models/FineTuningJobHyperparametersBatchSizeChoiceEnum.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.FineTuning -{ - internal readonly partial struct FineTuningJobHyperparametersBatchSizeChoiceEnum : IEquatable - { - private readonly string _value; - private const string AutoValue = "auto"; - - public FineTuningJobHyperparametersBatchSizeChoiceEnum(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static FineTuningJobHyperparametersBatchSizeChoiceEnum Auto { get; } = new FineTuningJobHyperparametersBatchSizeChoiceEnum(AutoValue); - - public static bool operator ==(FineTuningJobHyperparametersBatchSizeChoiceEnum left, FineTuningJobHyperparametersBatchSizeChoiceEnum right) => left.Equals(right); - - public static bool operator !=(FineTuningJobHyperparametersBatchSizeChoiceEnum left, FineTuningJobHyperparametersBatchSizeChoiceEnum right) => !left.Equals(right); - - public static implicit operator FineTuningJobHyperparametersBatchSizeChoiceEnum(string value) => new FineTuningJobHyperparametersBatchSizeChoiceEnum(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FineTuningJobHyperparametersBatchSizeChoiceEnum other && Equals(other); - - public bool Equals(FineTuningJobHyperparametersBatchSizeChoiceEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum.cs b/.dotnet/src/Generated/Models/FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum.cs deleted file mode 100644 index 87c2d5e3c..000000000 --- a/.dotnet/src/Generated/Models/FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.FineTuning -{ - internal readonly partial struct FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum : IEquatable - { - private readonly string _value; - private const string AutoValue = "auto"; - - public FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum Auto { get; } = new FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(AutoValue); - - public static bool operator ==(FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum left, FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum right) => left.Equals(right); - - public static bool operator !=(FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum left, FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum right) => !left.Equals(right); - - public static implicit operator FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(string value) => new FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum other && Equals(other); - - public bool Equals(FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/FineTuningJobHyperparametersNEpochsChoiceEnum.cs b/.dotnet/src/Generated/Models/FineTuningJobHyperparametersNEpochsChoiceEnum.cs deleted file mode 100644 index f4b40d5f3..000000000 --- a/.dotnet/src/Generated/Models/FineTuningJobHyperparametersNEpochsChoiceEnum.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.FineTuning -{ - internal readonly partial struct FineTuningJobHyperparametersNEpochsChoiceEnum : IEquatable - { - private readonly string _value; - private const string AutoValue = "auto"; - - public FineTuningJobHyperparametersNEpochsChoiceEnum(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static FineTuningJobHyperparametersNEpochsChoiceEnum Auto { get; } = new FineTuningJobHyperparametersNEpochsChoiceEnum(AutoValue); - - public static bool operator ==(FineTuningJobHyperparametersNEpochsChoiceEnum left, FineTuningJobHyperparametersNEpochsChoiceEnum right) => left.Equals(right); - - public static bool operator !=(FineTuningJobHyperparametersNEpochsChoiceEnum left, FineTuningJobHyperparametersNEpochsChoiceEnum right) => !left.Equals(right); - - public static implicit operator FineTuningJobHyperparametersNEpochsChoiceEnum(string value) => new FineTuningJobHyperparametersNEpochsChoiceEnum(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FineTuningJobHyperparametersNEpochsChoiceEnum other && Equals(other); - - public bool Equals(FineTuningJobHyperparametersNEpochsChoiceEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/FineTuningOptions.Serialization.cs b/.dotnet/src/Generated/Models/FineTuningOptions.Serialization.cs index eeaf45f5e..461e0d5ca 100644 --- a/.dotnet/src/Generated/Models/FineTuningOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/FineTuningOptions.Serialization.cs @@ -99,6 +99,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteNull("seed"u8); } } + if (Optional.IsDefined(Method) && _additionalBinaryDataProperties?.ContainsKey("method") != true) + { + writer.WritePropertyName("method"u8); + writer.WriteObjectValue(Method, options); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -146,6 +151,7 @@ internal static FineTuningOptions DeserializeFineTuningOptions(JsonElement eleme string validationFile = default; IList integrations = default; int? seed = default; + InternalTodoFineTuneMethod @method = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -212,6 +218,15 @@ internal static FineTuningOptions DeserializeFineTuningOptions(JsonElement eleme seed = prop.Value.GetInt32(); continue; } + if (prop.NameEquals("method"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @method = InternalTodoFineTuneMethod.DeserializeInternalTodoFineTuneMethod(prop.Value, options); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -225,6 +240,7 @@ internal static FineTuningOptions DeserializeFineTuningOptions(JsonElement eleme validationFile, integrations ?? new ChangeTrackingList(), seed, + @method, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/FineTuningOptions.cs b/.dotnet/src/Generated/Models/FineTuningOptions.cs index 1fece15c9..d3b1e74f5 100644 --- a/.dotnet/src/Generated/Models/FineTuningOptions.cs +++ b/.dotnet/src/Generated/Models/FineTuningOptions.cs @@ -21,7 +21,7 @@ public FineTuningOptions(InternalCreateFineTuningJobRequestModel model, string t Integrations = new ChangeTrackingList(); } - internal FineTuningOptions(InternalCreateFineTuningJobRequestModel model, string trainingFile, HyperparameterOptions hyperparameters, string suffix, string validationFile, IList integrations, int? seed, IDictionary additionalBinaryDataProperties) + internal FineTuningOptions(InternalCreateFineTuningJobRequestModel model, string trainingFile, HyperparameterOptions hyperparameters, string suffix, string validationFile, IList integrations, int? seed, InternalTodoFineTuneMethod @method, IDictionary additionalBinaryDataProperties) { Model = model; TrainingFile = trainingFile; @@ -30,6 +30,7 @@ internal FineTuningOptions(InternalCreateFineTuningJobRequestModel model, string ValidationFile = validationFile; Integrations = integrations; Seed = seed; + Method = @method; _additionalBinaryDataProperties = additionalBinaryDataProperties; } @@ -47,6 +48,8 @@ internal FineTuningOptions(InternalCreateFineTuningJobRequestModel model, string public int? Seed { get; set; } + public InternalTodoFineTuneMethod Method { get; set; } + internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/GeneratedSpeechVoice.cs b/.dotnet/src/Generated/Models/GeneratedSpeechVoice.cs index 7f18f9eed..d224a73ec 100644 --- a/.dotnet/src/Generated/Models/GeneratedSpeechVoice.cs +++ b/.dotnet/src/Generated/Models/GeneratedSpeechVoice.cs @@ -12,10 +12,13 @@ namespace OpenAI.Audio { private readonly string _value; private const string AlloyValue = "alloy"; + private const string AshValue = "ash"; + private const string CoralValue = "coral"; private const string EchoValue = "echo"; private const string FableValue = "fable"; private const string OnyxValue = "onyx"; private const string NovaValue = "nova"; + private const string SageValue = "sage"; private const string ShimmerValue = "shimmer"; public GeneratedSpeechVoice(string value) @@ -27,6 +30,10 @@ public GeneratedSpeechVoice(string value) public static GeneratedSpeechVoice Alloy { get; } = new GeneratedSpeechVoice(AlloyValue); + public static GeneratedSpeechVoice Ash { get; } = new GeneratedSpeechVoice(AshValue); + + public static GeneratedSpeechVoice Coral { get; } = new GeneratedSpeechVoice(CoralValue); + public static GeneratedSpeechVoice Echo { get; } = new GeneratedSpeechVoice(EchoValue); public static GeneratedSpeechVoice Fable { get; } = new GeneratedSpeechVoice(FableValue); @@ -35,6 +42,8 @@ public GeneratedSpeechVoice(string value) public static GeneratedSpeechVoice Nova { get; } = new GeneratedSpeechVoice(NovaValue); + public static GeneratedSpeechVoice Sage { get; } = new GeneratedSpeechVoice(SageValue); + public static GeneratedSpeechVoice Shimmer { get; } = new GeneratedSpeechVoice(ShimmerValue); public static bool operator ==(GeneratedSpeechVoice left, GeneratedSpeechVoice right) => left.Equals(right); diff --git a/.dotnet/src/Generated/Models/HyperparameterBatchSize.cs b/.dotnet/src/Generated/Models/HyperparameterBatchSize.cs deleted file mode 100644 index b223df728..000000000 --- a/.dotnet/src/Generated/Models/HyperparameterBatchSize.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.FineTuning -{ - internal readonly partial struct HyperparameterBatchSize : IEquatable - { - private readonly string _value; - private const string AutoValue = "auto"; - - public HyperparameterBatchSize(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static HyperparameterBatchSize Auto { get; } = new HyperparameterBatchSize(AutoValue); - - public static bool operator ==(HyperparameterBatchSize left, HyperparameterBatchSize right) => left.Equals(right); - - public static bool operator !=(HyperparameterBatchSize left, HyperparameterBatchSize right) => !left.Equals(right); - - public static implicit operator HyperparameterBatchSize(string value) => new HyperparameterBatchSize(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is HyperparameterBatchSize other && Equals(other); - - public bool Equals(HyperparameterBatchSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/HyperparameterCycleCount.cs b/.dotnet/src/Generated/Models/HyperparameterCycleCount.cs deleted file mode 100644 index 12306c291..000000000 --- a/.dotnet/src/Generated/Models/HyperparameterCycleCount.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.FineTuning -{ - internal readonly partial struct HyperparameterCycleCount : IEquatable - { - private readonly string _value; - private const string AutoValue = "auto"; - - public HyperparameterCycleCount(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static HyperparameterCycleCount Auto { get; } = new HyperparameterCycleCount(AutoValue); - - public static bool operator ==(HyperparameterCycleCount left, HyperparameterCycleCount right) => left.Equals(right); - - public static bool operator !=(HyperparameterCycleCount left, HyperparameterCycleCount right) => !left.Equals(right); - - public static implicit operator HyperparameterCycleCount(string value) => new HyperparameterCycleCount(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is HyperparameterCycleCount other && Equals(other); - - public bool Equals(HyperparameterCycleCount other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/HyperparameterLearningRate.cs b/.dotnet/src/Generated/Models/HyperparameterLearningRate.cs deleted file mode 100644 index 58643912a..000000000 --- a/.dotnet/src/Generated/Models/HyperparameterLearningRate.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.FineTuning -{ - internal readonly partial struct HyperparameterLearningRate : IEquatable - { - private readonly string _value; - private const string AutoValue = "auto"; - - public HyperparameterLearningRate(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static HyperparameterLearningRate Auto { get; } = new HyperparameterLearningRate(AutoValue); - - public static bool operator ==(HyperparameterLearningRate left, HyperparameterLearningRate right) => left.Equals(right); - - public static bool operator !=(HyperparameterLearningRate left, HyperparameterLearningRate right) => !left.Equals(right); - - public static implicit operator HyperparameterLearningRate(string value) => new HyperparameterLearningRate(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is HyperparameterLearningRate other && Equals(other); - - public bool Equals(HyperparameterLearningRate other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/HyperparameterOptions.Serialization.cs b/.dotnet/src/Generated/Models/HyperparameterOptions.Serialization.cs index 1e3d8a420..5b9bc3c28 100644 --- a/.dotnet/src/Generated/Models/HyperparameterOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/HyperparameterOptions.Serialization.cs @@ -27,18 +27,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(HyperparameterOptions)} does not support writing '{format}' format."); } - if (Optional.IsDefined(NEpochs) && _additionalBinaryDataProperties?.ContainsKey("n_epochs") != true) - { - writer.WritePropertyName("n_epochs"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(NEpochs); -#else - using (JsonDocument document = JsonDocument.Parse(NEpochs)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } if (Optional.IsDefined(BatchSize) && _additionalBinaryDataProperties?.ContainsKey("batch_size") != true) { writer.WritePropertyName("batch_size"u8); @@ -61,6 +49,18 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { JsonSerializer.Serialize(writer, document.RootElement); } +#endif + } + if (Optional.IsDefined(NEpochs) && _additionalBinaryDataProperties?.ContainsKey("n_epochs") != true) + { + writer.WritePropertyName("n_epochs"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(NEpochs); +#else + using (JsonDocument document = JsonDocument.Parse(NEpochs)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } #endif } if (true && _additionalBinaryDataProperties != null) @@ -103,37 +103,37 @@ internal static HyperparameterOptions DeserializeHyperparameterOptions(JsonEleme { return null; } - BinaryData nEpochs = default; BinaryData batchSize = default; BinaryData learningRateMultiplier = default; + BinaryData nEpochs = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("n_epochs"u8)) + if (prop.NameEquals("batch_size"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nEpochs = BinaryData.FromString(prop.Value.GetRawText()); + batchSize = BinaryData.FromString(prop.Value.GetRawText()); continue; } - if (prop.NameEquals("batch_size"u8)) + if (prop.NameEquals("learning_rate_multiplier"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - batchSize = BinaryData.FromString(prop.Value.GetRawText()); + learningRateMultiplier = BinaryData.FromString(prop.Value.GetRawText()); continue; } - if (prop.NameEquals("learning_rate_multiplier"u8)) + if (prop.NameEquals("n_epochs"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - learningRateMultiplier = BinaryData.FromString(prop.Value.GetRawText()); + nEpochs = BinaryData.FromString(prop.Value.GetRawText()); continue; } if (true) @@ -141,7 +141,7 @@ internal static HyperparameterOptions DeserializeHyperparameterOptions(JsonEleme additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new HyperparameterOptions(nEpochs, batchSize, learningRateMultiplier, additionalBinaryDataProperties); + return new HyperparameterOptions(batchSize, learningRateMultiplier, nEpochs, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/HyperparameterOptions.cs b/.dotnet/src/Generated/Models/HyperparameterOptions.cs index bf3cd076e..7f7363911 100644 --- a/.dotnet/src/Generated/Models/HyperparameterOptions.cs +++ b/.dotnet/src/Generated/Models/HyperparameterOptions.cs @@ -15,20 +15,20 @@ public HyperparameterOptions() { } - internal HyperparameterOptions(BinaryData nEpochs, BinaryData batchSize, BinaryData learningRateMultiplier, IDictionary additionalBinaryDataProperties) + internal HyperparameterOptions(BinaryData batchSize, BinaryData learningRateMultiplier, BinaryData nEpochs, IDictionary additionalBinaryDataProperties) { - NEpochs = nEpochs; BatchSize = batchSize; LearningRateMultiplier = learningRateMultiplier; + NEpochs = nEpochs; _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public BinaryData NEpochs { get; set; } - public BinaryData BatchSize { get; set; } public BinaryData LearningRateMultiplier { get; set; } + public BinaryData NEpochs { get; set; } + internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/InternalCreateAssistantRequestModel.cs b/.dotnet/src/Generated/Models/InternalCreateAssistantRequestModel.cs index b92d51fc7..409d14569 100644 --- a/.dotnet/src/Generated/Models/InternalCreateAssistantRequestModel.cs +++ b/.dotnet/src/Generated/Models/InternalCreateAssistantRequestModel.cs @@ -12,6 +12,7 @@ namespace OpenAI.Assistants { private readonly string _value; private const string Gpt4oValue = "gpt-4o"; + private const string Gpt4o20241120Value = "gpt-4o-2024-11-20"; private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; private const string Gpt4oMiniValue = "gpt-4o-mini"; @@ -44,6 +45,8 @@ public InternalCreateAssistantRequestModel(string value) public static InternalCreateAssistantRequestModel Gpt4o { get; } = new InternalCreateAssistantRequestModel(Gpt4oValue); + public static InternalCreateAssistantRequestModel Gpt4o20241120 { get; } = new InternalCreateAssistantRequestModel(Gpt4o20241120Value); + public static InternalCreateAssistantRequestModel Gpt4o20240806 { get; } = new InternalCreateAssistantRequestModel(Gpt4o20240806Value); public static InternalCreateAssistantRequestModel Gpt4o20240513 { get; } = new InternalCreateAssistantRequestModel(Gpt4o20240513Value); diff --git a/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs b/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs index 4afaa705b..d4271293a 100644 --- a/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs +++ b/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs @@ -11,17 +11,21 @@ namespace OpenAI.Chat internal readonly partial struct InternalCreateChatCompletionRequestModel : IEquatable { private readonly string _value; + private const string O1Value = "o1"; + private const string O120241217Value = "o1-2024-12-17"; private const string O1PreviewValue = "o1-preview"; private const string O1Preview20240912Value = "o1-preview-2024-09-12"; private const string O1MiniValue = "o1-mini"; private const string O1Mini20240912Value = "o1-mini-2024-09-12"; private const string Gpt4oValue = "gpt-4o"; + private const string Gpt4o20241120Value = "gpt-4o-2024-11-20"; private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; - private const string Gpt4oRealtimePreviewValue = "gpt-4o-realtime-preview"; - private const string Gpt4oRealtimePreview20241001Value = "gpt-4o-realtime-preview-2024-10-01"; private const string Gpt4oAudioPreviewValue = "gpt-4o-audio-preview"; private const string Gpt4oAudioPreview20241001Value = "gpt-4o-audio-preview-2024-10-01"; + private const string Gpt4oAudioPreview20241217Value = "gpt-4o-audio-preview-2024-12-17"; + private const string Gpt4oMiniAudioPreviewValue = "gpt-4o-mini-audio-preview"; + private const string Gpt4oMiniAudioPreview20241217Value = "gpt-4o-mini-audio-preview-2024-12-17"; private const string Chatgpt4oLatestValue = "chatgpt-4o-latest"; private const string Gpt4oMiniValue = "gpt-4o-mini"; private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; @@ -52,6 +56,10 @@ public InternalCreateChatCompletionRequestModel(string value) _value = value; } + public static InternalCreateChatCompletionRequestModel O1 { get; } = new InternalCreateChatCompletionRequestModel(O1Value); + + public static InternalCreateChatCompletionRequestModel O120241217 { get; } = new InternalCreateChatCompletionRequestModel(O120241217Value); + public static InternalCreateChatCompletionRequestModel O1Preview { get; } = new InternalCreateChatCompletionRequestModel(O1PreviewValue); public static InternalCreateChatCompletionRequestModel O1Preview20240912 { get; } = new InternalCreateChatCompletionRequestModel(O1Preview20240912Value); @@ -62,18 +70,22 @@ public InternalCreateChatCompletionRequestModel(string value) public static InternalCreateChatCompletionRequestModel Gpt4o { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oValue); + public static InternalCreateChatCompletionRequestModel Gpt4o20241120 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4o20241120Value); + public static InternalCreateChatCompletionRequestModel Gpt4o20240806 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4o20240806Value); public static InternalCreateChatCompletionRequestModel Gpt4o20240513 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4o20240513Value); - public static InternalCreateChatCompletionRequestModel Gpt4oRealtimePreview { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oRealtimePreviewValue); - - public static InternalCreateChatCompletionRequestModel Gpt4oRealtimePreview20241001 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oRealtimePreview20241001Value); - public static InternalCreateChatCompletionRequestModel Gpt4oAudioPreview { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oAudioPreviewValue); public static InternalCreateChatCompletionRequestModel Gpt4oAudioPreview20241001 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oAudioPreview20241001Value); + public static InternalCreateChatCompletionRequestModel Gpt4oAudioPreview20241217 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oAudioPreview20241217Value); + + public static InternalCreateChatCompletionRequestModel Gpt4oMiniAudioPreview { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oMiniAudioPreviewValue); + + public static InternalCreateChatCompletionRequestModel Gpt4oMiniAudioPreview20241217 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oMiniAudioPreview20241217Value); + public static InternalCreateChatCompletionRequestModel Chatgpt4oLatest { get; } = new InternalCreateChatCompletionRequestModel(Chatgpt4oLatestValue); public static InternalCreateChatCompletionRequestModel Gpt4oMini { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oMiniValue); diff --git a/.dotnet/src/Generated/Models/InternalCreateRunRequestModel.cs b/.dotnet/src/Generated/Models/InternalCreateRunRequestModel.cs index 71afae71b..7d3b0dbf0 100644 --- a/.dotnet/src/Generated/Models/InternalCreateRunRequestModel.cs +++ b/.dotnet/src/Generated/Models/InternalCreateRunRequestModel.cs @@ -12,6 +12,7 @@ namespace OpenAI.Assistants { private readonly string _value; private const string Gpt4oValue = "gpt-4o"; + private const string Gpt4o20241120Value = "gpt-4o-2024-11-20"; private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; private const string Gpt4oMiniValue = "gpt-4o-mini"; @@ -44,6 +45,8 @@ public InternalCreateRunRequestModel(string value) public static InternalCreateRunRequestModel Gpt4o { get; } = new InternalCreateRunRequestModel(Gpt4oValue); + public static InternalCreateRunRequestModel Gpt4o20241120 { get; } = new InternalCreateRunRequestModel(Gpt4o20241120Value); + public static InternalCreateRunRequestModel Gpt4o20240806 { get; } = new InternalCreateRunRequestModel(Gpt4o20240806Value); public static InternalCreateRunRequestModel Gpt4o20240513 { get; } = new InternalCreateRunRequestModel(Gpt4o20240513Value); diff --git a/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequestModel.cs b/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequestModel.cs index 35e576c4a..d04dc1226 100644 --- a/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequestModel.cs +++ b/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequestModel.cs @@ -12,6 +12,7 @@ namespace OpenAI.Assistants { private readonly string _value; private const string Gpt4oValue = "gpt-4o"; + private const string Gpt4o20241120Value = "gpt-4o-2024-11-20"; private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; private const string Gpt4oMiniValue = "gpt-4o-mini"; @@ -44,6 +45,8 @@ public InternalCreateThreadAndRunRequestModel(string value) public static InternalCreateThreadAndRunRequestModel Gpt4o { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4oValue); + public static InternalCreateThreadAndRunRequestModel Gpt4o20241120 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4o20241120Value); + public static InternalCreateThreadAndRunRequestModel Gpt4o20240806 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4o20240806Value); public static InternalCreateThreadAndRunRequestModel Gpt4o20240513 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4o20240513Value); diff --git a/.dotnet/src/Generated/Models/InternalFineTuneSupervisedMethodHyperparameters.Serialization.cs b/.dotnet/src/Generated/Models/InternalFineTuneSupervisedMethodHyperparameters.Serialization.cs new file mode 100644 index 000000000..a97f55cc1 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalFineTuneSupervisedMethodHyperparameters.Serialization.cs @@ -0,0 +1,196 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.FineTuning +{ + internal partial class InternalFineTuneSupervisedMethodHyperparameters : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFineTuneSupervisedMethodHyperparameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(BatchSize) && _additionalBinaryDataProperties?.ContainsKey("batch_size") != true) + { + writer.WritePropertyName("batch_size"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(BatchSize); +#else + using (JsonDocument document = JsonDocument.Parse(BatchSize)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(LearningRateMultiplier) && _additionalBinaryDataProperties?.ContainsKey("learning_rate_multiplier") != true) + { + writer.WritePropertyName("learning_rate_multiplier"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(LearningRateMultiplier); +#else + using (JsonDocument document = JsonDocument.Parse(LearningRateMultiplier)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(NEpochs) && _additionalBinaryDataProperties?.ContainsKey("n_epochs") != true) + { + writer.WritePropertyName("n_epochs"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(NEpochs); +#else + using (JsonDocument document = JsonDocument.Parse(NEpochs)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalFineTuneSupervisedMethodHyperparameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalFineTuneSupervisedMethodHyperparameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFineTuneSupervisedMethodHyperparameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFineTuneSupervisedMethodHyperparameters(document.RootElement, options); + } + + internal static InternalFineTuneSupervisedMethodHyperparameters DeserializeInternalFineTuneSupervisedMethodHyperparameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData batchSize = default; + BinaryData learningRateMultiplier = default; + BinaryData nEpochs = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("batch_size"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + batchSize = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("learning_rate_multiplier"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + learningRateMultiplier = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("n_epochs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nEpochs = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFineTuneSupervisedMethodHyperparameters(batchSize, learningRateMultiplier, nEpochs, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFineTuneSupervisedMethodHyperparameters)} does not support writing '{options.Format}' format."); + } + } + + InternalFineTuneSupervisedMethodHyperparameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalFineTuneSupervisedMethodHyperparameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalFineTuneSupervisedMethodHyperparameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFineTuneSupervisedMethodHyperparameters)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalFineTuneSupervisedMethodHyperparameters internalFineTuneSupervisedMethodHyperparameters) + { + if (internalFineTuneSupervisedMethodHyperparameters == null) + { + return null; + } + return BinaryContent.Create(internalFineTuneSupervisedMethodHyperparameters, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalFineTuneSupervisedMethodHyperparameters(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalFineTuneSupervisedMethodHyperparameters(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalFineTuneSupervisedMethodHyperparameters.cs b/.dotnet/src/Generated/Models/InternalFineTuneSupervisedMethodHyperparameters.cs new file mode 100644 index 000000000..ff74ddb36 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalFineTuneSupervisedMethodHyperparameters.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.FineTuning +{ + internal partial class InternalFineTuneSupervisedMethodHyperparameters + { + private protected IDictionary _additionalBinaryDataProperties; + + public InternalFineTuneSupervisedMethodHyperparameters() + { + } + + internal InternalFineTuneSupervisedMethodHyperparameters(BinaryData batchSize, BinaryData learningRateMultiplier, BinaryData nEpochs, IDictionary additionalBinaryDataProperties) + { + BatchSize = batchSize; + LearningRateMultiplier = learningRateMultiplier; + NEpochs = nEpochs; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public BinaryData BatchSize { get; set; } + + public BinaryData LearningRateMultiplier { get; set; } + + public BinaryData NEpochs { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalFineTuningJobEventType.cs b/.dotnet/src/Generated/Models/InternalFineTuningJobEventType.cs new file mode 100644 index 000000000..eaa0fb90d --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalFineTuningJobEventType.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.FineTuning +{ + internal readonly partial struct InternalFineTuningJobEventType : IEquatable + { + private readonly string _value; + private const string MessageValue = "message"; + private const string MetricsValue = "metrics"; + + public InternalFineTuningJobEventType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalFineTuningJobEventType Message { get; } = new InternalFineTuningJobEventType(MessageValue); + + public static InternalFineTuningJobEventType Metrics { get; } = new InternalFineTuningJobEventType(MetricsValue); + + public static bool operator ==(InternalFineTuningJobEventType left, InternalFineTuningJobEventType right) => left.Equals(right); + + public static bool operator !=(InternalFineTuningJobEventType left, InternalFineTuningJobEventType right) => !left.Equals(right); + + public static implicit operator InternalFineTuningJobEventType(string value) => new InternalFineTuningJobEventType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalFineTuningJobEventType other && Equals(other); + + public bool Equals(InternalFineTuningJobEventType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalListFilesResponseObject.cs b/.dotnet/src/Generated/Models/InternalListFilesResponseObject.cs deleted file mode 100644 index 2fa2419c8..000000000 --- a/.dotnet/src/Generated/Models/InternalListFilesResponseObject.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Files -{ - internal readonly partial struct InternalListFilesResponseObject : IEquatable - { - private readonly string _value; - private const string ListValue = "list"; - - public InternalListFilesResponseObject(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static InternalListFilesResponseObject List { get; } = new InternalListFilesResponseObject(ListValue); - - public static bool operator ==(InternalListFilesResponseObject left, InternalListFilesResponseObject right) => left.Equals(right); - - public static bool operator !=(InternalListFilesResponseObject left, InternalListFilesResponseObject right) => !left.Equals(right); - - public static implicit operator InternalListFilesResponseObject(string value) => new InternalListFilesResponseObject(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListFilesResponseObject other && Equals(other); - - public bool Equals(InternalListFilesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/InternalPredictionContent.Serialization.cs b/.dotnet/src/Generated/Models/InternalPredictionContent.Serialization.cs new file mode 100644 index 000000000..b79bfe6cc --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalPredictionContent.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalPredictionContent : IJsonModel + { + internal InternalPredictionContent() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalPredictionContent)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (_additionalBinaryDataProperties?.ContainsKey("content") != true) + { + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalPredictionContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalPredictionContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalPredictionContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalPredictionContent(document.RootElement, options); + } + + internal static InternalPredictionContent DeserializeInternalPredictionContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalPredictionContentType @type = default; + BinaryData content = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InternalPredictionContentType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalPredictionContent(@type, content, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalPredictionContent)} does not support writing '{options.Format}' format."); + } + } + + InternalPredictionContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalPredictionContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalPredictionContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalPredictionContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalPredictionContent internalPredictionContent) + { + if (internalPredictionContent == null) + { + return null; + } + return BinaryContent.Create(internalPredictionContent, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalPredictionContent(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalPredictionContent(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalPredictionContent.cs b/.dotnet/src/Generated/Models/InternalPredictionContent.cs new file mode 100644 index 000000000..7277296b3 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalPredictionContent.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalPredictionContent + { + private protected IDictionary _additionalBinaryDataProperties; + + public InternalPredictionContent(BinaryData content) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + internal InternalPredictionContent(InternalPredictionContentType @type, BinaryData content, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Content = content; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public InternalPredictionContentType Type { get; } = "content"; + + public BinaryData Content { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalPredictionContentType.cs b/.dotnet/src/Generated/Models/InternalPredictionContentType.cs new file mode 100644 index 000000000..ea67f9935 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalPredictionContentType.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + internal readonly partial struct InternalPredictionContentType : IEquatable + { + private readonly string _value; + private const string ContentValue = "content"; + + public InternalPredictionContentType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalPredictionContentType Content { get; } = new InternalPredictionContentType(ContentValue); + + public static bool operator ==(InternalPredictionContentType left, InternalPredictionContentType right) => left.Equals(right); + + public static bool operator !=(InternalPredictionContentType left, InternalPredictionContentType right) => !left.Equals(right); + + public static implicit operator InternalPredictionContentType(string value) => new InternalPredictionContentType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalPredictionContentType other && Equals(other); + + public bool Equals(InternalPredictionContentType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCancel.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCancel.Serialization.cs index 6da7ef02c..892c4cb6b 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCancel.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCancel.Serialization.cs @@ -28,6 +28,11 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(InternalRealtimeClientEventResponseCancel)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(ResponseId) && _additionalBinaryDataProperties?.ContainsKey("response_id") != true) + { + writer.WritePropertyName("response_id"u8); + writer.WriteStringValue(ResponseId); + } } InternalRealtimeClientEventResponseCancel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalRealtimeClientEventResponseCancel)JsonModelCreateCore(ref reader, options); @@ -52,6 +57,7 @@ internal static InternalRealtimeClientEventResponseCancel DeserializeInternalRea InternalRealtimeClientEventType kind = default; string eventId = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string responseId = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) @@ -64,12 +70,17 @@ internal static InternalRealtimeClientEventResponseCancel DeserializeInternalRea eventId = prop.Value.GetString(); continue; } + if (prop.NameEquals("response_id"u8)) + { + responseId = prop.Value.GetString(); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRealtimeClientEventResponseCancel(kind, eventId, additionalBinaryDataProperties); + return new InternalRealtimeClientEventResponseCancel(kind, eventId, additionalBinaryDataProperties, responseId); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCancel.cs b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCancel.cs index 4e7a1b227..3694fdd28 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCancel.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCancel.cs @@ -13,8 +13,11 @@ public InternalRealtimeClientEventResponseCancel() : base(InternalRealtimeClient { } - internal InternalRealtimeClientEventResponseCancel(InternalRealtimeClientEventType kind, string eventId, IDictionary additionalBinaryDataProperties) : base(kind, eventId, additionalBinaryDataProperties) + internal InternalRealtimeClientEventResponseCancel(InternalRealtimeClientEventType kind, string eventId, IDictionary additionalBinaryDataProperties, string responseId) : base(kind, eventId, additionalBinaryDataProperties) { + ResponseId = responseId; } + + public string ResponseId { get; set; } } } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.Serialization.cs index 862ee53db..66c7331e1 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.Serialization.cs @@ -13,10 +13,6 @@ namespace OpenAI.RealtimeConversation { internal partial class InternalRealtimeClientEventResponseCreate : IJsonModel { - internal InternalRealtimeClientEventResponseCreate() - { - } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -32,7 +28,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(InternalRealtimeClientEventResponseCreate)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("response") != true) + if (Optional.IsDefined(Response) && _additionalBinaryDataProperties?.ContainsKey("response") != true) { writer.WritePropertyName("response"u8); writer.WriteObjectValue(Response, options); @@ -61,7 +57,7 @@ internal static InternalRealtimeClientEventResponseCreate DeserializeInternalRea InternalRealtimeClientEventType kind = default; string eventId = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - InternalRealtimeResponseOptions response = default; + ConversationResponseOptions response = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) @@ -76,7 +72,11 @@ internal static InternalRealtimeClientEventResponseCreate DeserializeInternalRea } if (prop.NameEquals("response"u8)) { - response = InternalRealtimeResponseOptions.DeserializeInternalRealtimeResponseOptions(prop.Value, options); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + response = ConversationResponseOptions.DeserializeConversationResponseOptions(prop.Value, options); continue; } if (true) diff --git a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.cs b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.cs index abdc82c41..9c358bf6e 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeClientEventResponseCreate.cs @@ -4,24 +4,20 @@ using System; using System.Collections.Generic; -using OpenAI; namespace OpenAI.RealtimeConversation { internal partial class InternalRealtimeClientEventResponseCreate : InternalRealtimeClientEvent { - public InternalRealtimeClientEventResponseCreate(InternalRealtimeResponseOptions response) : base(InternalRealtimeClientEventType.ResponseCreate) + public InternalRealtimeClientEventResponseCreate() : base(InternalRealtimeClientEventType.ResponseCreate) { - Argument.AssertNotNull(response, nameof(response)); - - Response = response; } - internal InternalRealtimeClientEventResponseCreate(InternalRealtimeClientEventType kind, string eventId, IDictionary additionalBinaryDataProperties, InternalRealtimeResponseOptions response) : base(kind, eventId, additionalBinaryDataProperties) + internal InternalRealtimeClientEventResponseCreate(InternalRealtimeClientEventType kind, string eventId, IDictionary additionalBinaryDataProperties, ConversationResponseOptions response) : base(kind, eventId, additionalBinaryDataProperties) { Response = response; } - public InternalRealtimeResponseOptions Response { get; } + public ConversationResponseOptions Response { get; set; } } } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeRequestSessionModel.cs b/.dotnet/src/Generated/Models/InternalRealtimeRequestSessionModel.cs new file mode 100644 index 000000000..b9a74844a --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRealtimeRequestSessionModel.cs @@ -0,0 +1,53 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + internal readonly partial struct InternalRealtimeRequestSessionModel : IEquatable + { + private readonly string _value; + private const string Gpt4oRealtimePreviewValue = "gpt-4o-realtime-preview"; + private const string Gpt4oRealtimePreview20241001Value = "gpt-4o-realtime-preview-2024-10-01"; + private const string Gpt4oRealtimePreview20241217Value = "gpt-4o-realtime-preview-2024-12-17"; + private const string Gpt4oMiniRealtimePreviewValue = "gpt-4o-mini-realtime-preview"; + private const string Gpt4oMiniRealtimePreview20241217Value = "gpt-4o-mini-realtime-preview-2024-12-17"; + + public InternalRealtimeRequestSessionModel(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalRealtimeRequestSessionModel Gpt4oRealtimePreview { get; } = new InternalRealtimeRequestSessionModel(Gpt4oRealtimePreviewValue); + + public static InternalRealtimeRequestSessionModel Gpt4oRealtimePreview20241001 { get; } = new InternalRealtimeRequestSessionModel(Gpt4oRealtimePreview20241001Value); + + public static InternalRealtimeRequestSessionModel Gpt4oRealtimePreview20241217 { get; } = new InternalRealtimeRequestSessionModel(Gpt4oRealtimePreview20241217Value); + + public static InternalRealtimeRequestSessionModel Gpt4oMiniRealtimePreview { get; } = new InternalRealtimeRequestSessionModel(Gpt4oMiniRealtimePreviewValue); + + public static InternalRealtimeRequestSessionModel Gpt4oMiniRealtimePreview20241217 { get; } = new InternalRealtimeRequestSessionModel(Gpt4oMiniRealtimePreview20241217Value); + + public static bool operator ==(InternalRealtimeRequestSessionModel left, InternalRealtimeRequestSessionModel right) => left.Equals(right); + + public static bool operator !=(InternalRealtimeRequestSessionModel left, InternalRealtimeRequestSessionModel right) => !left.Equals(right); + + public static implicit operator InternalRealtimeRequestSessionModel(string value) => new InternalRealtimeRequestSessionModel(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRealtimeRequestSessionModel other && Equals(other); + + public bool Equals(InternalRealtimeRequestSessionModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponse.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponse.Serialization.cs index 51ad43ae0..f66ba7b1e 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponse.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponse.Serialization.cs @@ -13,10 +13,6 @@ namespace OpenAI.RealtimeConversation { internal partial class InternalRealtimeResponse : IJsonModel { - internal InternalRealtimeResponse() - { - } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,39 +27,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(InternalRealtimeResponse)} does not support writing '{format}' format."); } - if (_additionalBinaryDataProperties?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (_additionalBinaryDataProperties?.ContainsKey("id") != true) + if (Optional.IsDefined(Id) && _additionalBinaryDataProperties?.ContainsKey("id") != true) { writer.WritePropertyName("id"u8); writer.WriteStringValue(Id); } - if (_additionalBinaryDataProperties?.ContainsKey("status") != true) + if (Optional.IsDefined(Object) && _additionalBinaryDataProperties?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.Value.ToString()); + } + if (Optional.IsDefined(Status) && _additionalBinaryDataProperties?.ContainsKey("status") != true) { writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); + writer.WriteStringValue(Status.Value.ToString()); } - if (_additionalBinaryDataProperties?.ContainsKey("status_details") != true) + if (Optional.IsDefined(StatusDetails) && _additionalBinaryDataProperties?.ContainsKey("status_details") != true) { - if (StatusDetails != null) + writer.WritePropertyName("status_details"u8); + writer.WriteObjectValue(StatusDetails, options); + } + if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) + { + if (Metadata != null) { - writer.WritePropertyName("status_details"u8); - writer.WriteObjectValue(StatusDetails, options); + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); } else { - writer.WriteNull("statusDetails"u8); + writer.WriteNull("metadata"u8); } } - if (_additionalBinaryDataProperties?.ContainsKey("usage") != true) + if (Optional.IsDefined(Usage) && _additionalBinaryDataProperties?.ContainsKey("usage") != true) { writer.WritePropertyName("usage"u8); writer.WriteObjectValue(Usage, options); } - if (_additionalBinaryDataProperties?.ContainsKey("output") != true) + if (Optional.IsCollectionDefined(Output) && _additionalBinaryDataProperties?.ContainsKey("output") != true) { writer.WritePropertyName("output"u8); writer.WriteStartArray(); @@ -113,27 +125,36 @@ internal static InternalRealtimeResponse DeserializeInternalRealtimeResponse(Jso { return null; } - InternalRealtimeResponseObject @object = default; string id = default; - ConversationStatus status = default; + InternalRealtimeResponseObject? @object = default; + ConversationStatus? status = default; ConversationStatusDetails statusDetails = default; + IDictionary metadata = default; ConversationTokenUsage usage = default; IReadOnlyList output = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("object"u8)) + if (prop.NameEquals("id"u8)) { - @object = new InternalRealtimeResponseObject(prop.Value.GetString()); + id = prop.Value.GetString(); continue; } - if (prop.NameEquals("id"u8)) + if (prop.NameEquals("object"u8)) { - id = prop.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @object = new InternalRealtimeResponseObject(prop.Value.GetString()); continue; } if (prop.NameEquals("status"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } status = new ConversationStatus(prop.Value.GetString()); continue; } @@ -141,19 +162,47 @@ internal static InternalRealtimeResponse DeserializeInternalRealtimeResponse(Jso { if (prop.Value.ValueKind == JsonValueKind.Null) { - statusDetails = null; continue; } statusDetails = ConversationStatusDetails.DeserializeConversationStatusDetails(prop.Value, options); continue; } + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } if (prop.NameEquals("usage"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } usage = ConversationTokenUsage.DeserializeConversationTokenUsage(prop.Value, options); continue; } if (prop.NameEquals("output"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } List array = new List(); foreach (var item in prop.Value.EnumerateArray()) { @@ -168,12 +217,13 @@ internal static InternalRealtimeResponse DeserializeInternalRealtimeResponse(Jso } } return new InternalRealtimeResponse( - @object, id, + @object, status, statusDetails, + metadata ?? new ChangeTrackingDictionary(), usage, - output, + output ?? new ChangeTrackingList(), additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponse.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponse.cs index 50f4a0b40..c087e6191 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponse.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponse.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -using System.Linq; +using OpenAI; namespace OpenAI.RealtimeConversation { @@ -12,34 +12,34 @@ internal partial class InternalRealtimeResponse { private protected IDictionary _additionalBinaryDataProperties; - internal InternalRealtimeResponse(string id, ConversationStatus status, ConversationStatusDetails statusDetails, ConversationTokenUsage usage, IEnumerable output) + internal InternalRealtimeResponse() { - Id = id; - Status = status; - StatusDetails = statusDetails; - Usage = usage; - Output = output.ToList(); + Metadata = new ChangeTrackingDictionary(); + Output = new ChangeTrackingList(); } - internal InternalRealtimeResponse(InternalRealtimeResponseObject @object, string id, ConversationStatus status, ConversationStatusDetails statusDetails, ConversationTokenUsage usage, IReadOnlyList output, IDictionary additionalBinaryDataProperties) + internal InternalRealtimeResponse(string id, InternalRealtimeResponseObject? @object, ConversationStatus? status, ConversationStatusDetails statusDetails, IDictionary metadata, ConversationTokenUsage usage, IReadOnlyList output, IDictionary additionalBinaryDataProperties) { - Object = @object; Id = id; + Object = @object; Status = status; StatusDetails = statusDetails; + Metadata = metadata; Usage = usage; Output = output; _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public InternalRealtimeResponseObject Object { get; } = "realtime.response"; - public string Id { get; } - public ConversationStatus Status { get; } + public InternalRealtimeResponseObject? Object { get; } + + public ConversationStatus? Status { get; } public ConversationStatusDetails StatusDetails { get; } + public IDictionary Metadata { get; } + public ConversationTokenUsage Usage { get; } internal IDictionary SerializedAdditionalRawData diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseOptions.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseOptions.cs deleted file mode 100644 index 9d27614fb..000000000 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponseOptions.cs +++ /dev/null @@ -1,54 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using OpenAI; - -namespace OpenAI.RealtimeConversation -{ - internal partial class InternalRealtimeResponseOptions - { - private protected IDictionary _additionalBinaryDataProperties; - - public InternalRealtimeResponseOptions() - { - Modalities = new ChangeTrackingList(); - Tools = new ChangeTrackingList(); - } - - internal InternalRealtimeResponseOptions(IList modalities, string instructions, ConversationVoice? voice, ConversationAudioFormat? outputAudioFormat, IList tools, float? temperature, BinaryData maxOutputTokens, BinaryData toolChoice, IDictionary additionalBinaryDataProperties) - { - Modalities = modalities; - Instructions = instructions; - Voice = voice; - OutputAudioFormat = outputAudioFormat; - Tools = tools; - Temperature = temperature; - MaxOutputTokens = maxOutputTokens; - ToolChoice = toolChoice; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - public IList Modalities { get; } - - public string Instructions { get; set; } - - public ConversationVoice? Voice { get; set; } - - public ConversationAudioFormat? OutputAudioFormat { get; set; } - - public IList Tools { get; } - - public float? Temperature { get; set; } - - public BinaryData MaxOutputTokens { get; set; } - - internal IDictionary SerializedAdditionalRawData - { - get => _additionalBinaryDataProperties; - set => _additionalBinaryDataProperties = value; - } - } -} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsError.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsError.Serialization.cs new file mode 100644 index 000000000..897183a15 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsError.Serialization.cs @@ -0,0 +1,152 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + internal partial class InternalRealtimeResponseStatusDetailsError : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRealtimeResponseStatusDetailsError)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Type) && _additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (Optional.IsDefined(Code) && _additionalBinaryDataProperties?.ContainsKey("code") != true) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalRealtimeResponseStatusDetailsError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalRealtimeResponseStatusDetailsError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRealtimeResponseStatusDetailsError)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRealtimeResponseStatusDetailsError(document.RootElement, options); + } + + internal static InternalRealtimeResponseStatusDetailsError DeserializeInternalRealtimeResponseStatusDetailsError(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + string code = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("code"u8)) + { + code = prop.Value.GetString(); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalRealtimeResponseStatusDetailsError(@type, code, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRealtimeResponseStatusDetailsError)} does not support writing '{options.Format}' format."); + } + } + + InternalRealtimeResponseStatusDetailsError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalRealtimeResponseStatusDetailsError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalRealtimeResponseStatusDetailsError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRealtimeResponseStatusDetailsError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalRealtimeResponseStatusDetailsError internalRealtimeResponseStatusDetailsError) + { + if (internalRealtimeResponseStatusDetailsError == null) + { + return null; + } + return BinaryContent.Create(internalRealtimeResponseStatusDetailsError, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalRealtimeResponseStatusDetailsError(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalRealtimeResponseStatusDetailsError(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsError.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsError.cs new file mode 100644 index 000000000..6a93dd32e --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsError.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.RealtimeConversation +{ + internal partial class InternalRealtimeResponseStatusDetailsError + { + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalRealtimeResponseStatusDetailsError() + { + } + + internal InternalRealtimeResponseStatusDetailsError(string @type, string code, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Code = code; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public string Type { get; } + + public string Code { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsType.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsType.cs new file mode 100644 index 000000000..19492c908 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseStatusDetailsType.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + internal readonly partial struct InternalRealtimeResponseStatusDetailsType : IEquatable + { + private readonly string _value; + private const string CompletedValue = "completed"; + private const string CancelledValue = "cancelled"; + private const string FailedValue = "failed"; + private const string IncompleteValue = "incomplete"; + + public InternalRealtimeResponseStatusDetailsType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalRealtimeResponseStatusDetailsType Completed { get; } = new InternalRealtimeResponseStatusDetailsType(CompletedValue); + + public static InternalRealtimeResponseStatusDetailsType Cancelled { get; } = new InternalRealtimeResponseStatusDetailsType(CancelledValue); + + public static InternalRealtimeResponseStatusDetailsType Failed { get; } = new InternalRealtimeResponseStatusDetailsType(FailedValue); + + public static InternalRealtimeResponseStatusDetailsType Incomplete { get; } = new InternalRealtimeResponseStatusDetailsType(IncompleteValue); + + public static bool operator ==(InternalRealtimeResponseStatusDetailsType left, InternalRealtimeResponseStatusDetailsType right) => left.Equals(right); + + public static bool operator !=(InternalRealtimeResponseStatusDetailsType left, InternalRealtimeResponseStatusDetailsType right) => !left.Equals(right); + + public static implicit operator InternalRealtimeResponseStatusDetailsType(string value) => new InternalRealtimeResponseStatusDetailsType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRealtimeResponseStatusDetailsType other && Equals(other); + + public bool Equals(InternalRealtimeResponseStatusDetailsType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeServerEventErrorError.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeServerEventErrorError.Serialization.cs index b9180e740..6204d19b9 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeServerEventErrorError.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeServerEventErrorError.Serialization.cs @@ -13,6 +13,10 @@ namespace OpenAI.RealtimeConversation { internal partial class InternalRealtimeServerEventErrorError : IJsonModel { + internal InternalRealtimeServerEventErrorError() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -27,30 +31,51 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(InternalRealtimeServerEventErrorError)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Type) && _additionalBinaryDataProperties?.ContainsKey("type") != true) + if (_additionalBinaryDataProperties?.ContainsKey("type") != true) { writer.WritePropertyName("type"u8); writer.WriteStringValue(Type); } if (Optional.IsDefined(Code) && _additionalBinaryDataProperties?.ContainsKey("code") != true) { - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code); + if (Code != null) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + else + { + writer.WriteNull("code"u8); + } } - if (Optional.IsDefined(Message) && _additionalBinaryDataProperties?.ContainsKey("message") != true) + if (_additionalBinaryDataProperties?.ContainsKey("message") != true) { writer.WritePropertyName("message"u8); writer.WriteStringValue(Message); } if (Optional.IsDefined(Param) && _additionalBinaryDataProperties?.ContainsKey("param") != true) { - writer.WritePropertyName("param"u8); - writer.WriteStringValue(Param); + if (Param != null) + { + writer.WritePropertyName("param"u8); + writer.WriteStringValue(Param); + } + else + { + writer.WriteNull("param"u8); + } } if (Optional.IsDefined(EventId) && _additionalBinaryDataProperties?.ContainsKey("event_id") != true) { - writer.WritePropertyName("event_id"u8); - writer.WriteStringValue(EventId); + if (EventId != null) + { + writer.WritePropertyName("event_id"u8); + writer.WriteStringValue(EventId); + } + else + { + writer.WriteNull("eventId"u8); + } } if (true && _additionalBinaryDataProperties != null) { @@ -107,6 +132,11 @@ internal static InternalRealtimeServerEventErrorError DeserializeInternalRealtim } if (prop.NameEquals("code"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + code = null; + continue; + } code = prop.Value.GetString(); continue; } @@ -117,11 +147,21 @@ internal static InternalRealtimeServerEventErrorError DeserializeInternalRealtim } if (prop.NameEquals("param"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + @param = null; + continue; + } @param = prop.Value.GetString(); continue; } if (prop.NameEquals("event_id"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + eventId = null; + continue; + } eventId = prop.Value.GetString(); continue; } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeServerEventErrorError.cs b/.dotnet/src/Generated/Models/InternalRealtimeServerEventErrorError.cs index 41498342f..07233ba4a 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeServerEventErrorError.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeServerEventErrorError.cs @@ -11,8 +11,10 @@ internal partial class InternalRealtimeServerEventErrorError { private protected IDictionary _additionalBinaryDataProperties; - internal InternalRealtimeServerEventErrorError() + internal InternalRealtimeServerEventErrorError(string @type, string message) { + Type = @type; + Message = message; } internal InternalRealtimeServerEventErrorError(string @type, string code, string message, string @param, string eventId, IDictionary additionalBinaryDataProperties) diff --git a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.Serialization.cs b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.Serialization.cs index b58e9c1fa..20fd03648 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.Serialization.cs @@ -45,7 +45,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (_additionalBinaryDataProperties?.ContainsKey("file_search") != true) { writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); + writer.WriteObjectValue(FileSearch, options); } } @@ -72,7 +72,7 @@ internal static InternalRunStepDeltaStepDetailsToolCallsFileSearchObject Deseria IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); int index = default; string id = default; - InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch fileSearch = default; + InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) @@ -92,7 +92,7 @@ internal static InternalRunStepDeltaStepDetailsToolCallsFileSearchObject Deseria } if (prop.NameEquals("file_search"u8)) { - fileSearch = InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(prop.Value, options); + fileSearch = InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(prop.Value, options); continue; } if (true) diff --git a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.cs b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.cs index b0da34cf3..59052b52c 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.cs @@ -9,13 +9,13 @@ namespace OpenAI.Assistants { internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObject : InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject { - internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(int index, InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base("file_search") + internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(int index, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base("file_search") { Index = index; FileSearch = fileSearch; } - internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(string @type, IDictionary additionalBinaryDataProperties, int index, string id, InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base(@type, additionalBinaryDataProperties) + internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(string @type, IDictionary additionalBinaryDataProperties, int index, string id, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base(@type, additionalBinaryDataProperties) { Index = index; Id = id; @@ -25,7 +25,5 @@ internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(string @type, public int Index { get; } public string Id { get; } - - public InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch FileSearch { get; } } } diff --git a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs deleted file mode 100644 index 6b443b8b1..000000000 --- a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs +++ /dev/null @@ -1,170 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Assistants -{ - internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch)} does not support writing '{format}' format."); - } - if (true && Optional.IsCollectionDefined(Results) && _additionalBinaryDataProperties?.ContainsKey("results") != true) - { - writer.WritePropertyName("results"u8); - writer.WriteStartArray(); - foreach (RunStepFileSearchResult item in Results) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(RankingOptions) && _additionalBinaryDataProperties?.ContainsKey("ranking_options") != true) - { - writer.WritePropertyName("ranking_options"u8); - writer.WriteObjectValue(RankingOptions, options); - } - if (true && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - protected virtual InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, options); - } - - internal static InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList results = default; - FileSearchRankingOptions rankingOptions = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("results"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in prop.Value.EnumerateArray()) - { - array.Add(RunStepFileSearchResult.DeserializeRunStepFileSearchResult(item, options)); - } - results = array; - continue; - } - if (prop.NameEquals("ranking_options"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(prop.Value, options); - continue; - } - if (true) - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(results ?? new ChangeTrackingList(), rankingOptions, additionalBinaryDataProperties); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch)} does not support writing '{options.Format}' format."); - } - } - - InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - protected virtual InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch internalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch) - { - if (internalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch == null) - { - return null; - } - return BinaryContent.Create(internalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.cs b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.cs deleted file mode 100644 index 610b1286c..000000000 --- a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using OpenAI; - -namespace OpenAI.Assistants -{ - internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch - { - private protected IDictionary _additionalBinaryDataProperties; - - internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch() - { - Results = new ChangeTrackingList(); - } - - internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(IReadOnlyList results, FileSearchRankingOptions rankingOptions, IDictionary additionalBinaryDataProperties) - { - Results = results; - RankingOptions = rankingOptions; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - public IReadOnlyList Results { get; } - - internal IDictionary SerializedAdditionalRawData - { - get => _additionalBinaryDataProperties; - set => _additionalBinaryDataProperties = value; - } - } -} diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.Serialization.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.Serialization.cs index ee963279b..d6cb108b2 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.Serialization.cs @@ -32,6 +32,11 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObject)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } if (_additionalBinaryDataProperties?.ContainsKey("code_interpreter") != true) { writer.WritePropertyName("code_interpreter"u8); @@ -58,20 +63,20 @@ internal static InternalRunStepDetailsToolCallsCodeObject DeserializeInternalRun { return null; } - string id = default; Assistants.RunStepToolCallKind kind = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string id = default; InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = prop.Value.GetString(); + kind = prop.Value.GetString().ToRunStepToolCallKind(); continue; } - if (prop.NameEquals("type"u8)) + if (prop.NameEquals("id"u8)) { - kind = prop.Value.GetString().ToRunStepToolCallKind(); + id = prop.Value.GetString(); continue; } if (prop.NameEquals("code_interpreter"u8)) @@ -84,7 +89,7 @@ internal static InternalRunStepDetailsToolCallsCodeObject DeserializeInternalRun additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRunStepDetailsToolCallsCodeObject(id, kind, additionalBinaryDataProperties, codeInterpreter); + return new InternalRunStepDetailsToolCallsCodeObject(kind, additionalBinaryDataProperties, id, codeInterpreter); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.cs index 1901d9b3a..d6352e9c1 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.cs @@ -14,11 +14,13 @@ internal InternalRunStepDetailsToolCallsCodeObject(string id, InternalRunStepDet CodeInterpreter = codeInterpreter; } - internal InternalRunStepDetailsToolCallsCodeObject(string id, Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) : base(id, kind, additionalBinaryDataProperties) + internal InternalRunStepDetailsToolCallsCodeObject(Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, string id, InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) : base(id, kind, additionalBinaryDataProperties) { CodeInterpreter = codeInterpreter; } + public new string Id => _id ?? default; + public InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter CodeInterpreter { get; } } } diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.Serialization.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.Serialization.cs index c3383210e..45ac8525f 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.Serialization.cs @@ -32,6 +32,11 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObject)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } if (_additionalBinaryDataProperties?.ContainsKey("file_search") != true) { writer.WritePropertyName("file_search"u8); @@ -58,20 +63,20 @@ internal static InternalRunStepDetailsToolCallsFileSearchObject DeserializeInter { return null; } - string id = default; Assistants.RunStepToolCallKind kind = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string id = default; InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = prop.Value.GetString(); + kind = prop.Value.GetString().ToRunStepToolCallKind(); continue; } - if (prop.NameEquals("type"u8)) + if (prop.NameEquals("id"u8)) { - kind = prop.Value.GetString().ToRunStepToolCallKind(); + id = prop.Value.GetString(); continue; } if (prop.NameEquals("file_search"u8)) @@ -84,7 +89,7 @@ internal static InternalRunStepDetailsToolCallsFileSearchObject DeserializeInter additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRunStepDetailsToolCallsFileSearchObject(id, kind, additionalBinaryDataProperties, fileSearch); + return new InternalRunStepDetailsToolCallsFileSearchObject(kind, additionalBinaryDataProperties, id, fileSearch); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.cs index 3346c806c..5d0f596f2 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.cs @@ -14,11 +14,13 @@ internal InternalRunStepDetailsToolCallsFileSearchObject(string id, InternalRunS FileSearch = fileSearch; } - internal InternalRunStepDetailsToolCallsFileSearchObject(string id, Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base(id, kind, additionalBinaryDataProperties) + internal InternalRunStepDetailsToolCallsFileSearchObject(Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, string id, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base(id, kind, additionalBinaryDataProperties) { FileSearch = fileSearch; } + public new string Id => _id ?? default; + public InternalRunStepDetailsToolCallsFileSearchObjectFileSearch FileSearch { get; } } } diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.Serialization.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.Serialization.cs index b2de59874..7fa61d5e6 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.Serialization.cs @@ -32,6 +32,11 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObject)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } if (_additionalBinaryDataProperties?.ContainsKey("function") != true) { writer.WritePropertyName("function"u8); @@ -58,20 +63,20 @@ internal static InternalRunStepDetailsToolCallsFunctionObject DeserializeInterna { return null; } - string id = default; Assistants.RunStepToolCallKind kind = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string id = default; InternalRunStepDetailsToolCallsFunctionObjectFunction function = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = prop.Value.GetString(); + kind = prop.Value.GetString().ToRunStepToolCallKind(); continue; } - if (prop.NameEquals("type"u8)) + if (prop.NameEquals("id"u8)) { - kind = prop.Value.GetString().ToRunStepToolCallKind(); + id = prop.Value.GetString(); continue; } if (prop.NameEquals("function"u8)) @@ -84,7 +89,7 @@ internal static InternalRunStepDetailsToolCallsFunctionObject DeserializeInterna additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRunStepDetailsToolCallsFunctionObject(id, kind, additionalBinaryDataProperties, function); + return new InternalRunStepDetailsToolCallsFunctionObject(kind, additionalBinaryDataProperties, id, function); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.cs index a6c864fee..abe30aeb9 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.cs @@ -14,11 +14,13 @@ internal InternalRunStepDetailsToolCallsFunctionObject(string id, InternalRunSte Function = function; } - internal InternalRunStepDetailsToolCallsFunctionObject(string id, Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, InternalRunStepDetailsToolCallsFunctionObjectFunction function) : base(id, kind, additionalBinaryDataProperties) + internal InternalRunStepDetailsToolCallsFunctionObject(Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, string id, InternalRunStepDetailsToolCallsFunctionObjectFunction function) : base(id, kind, additionalBinaryDataProperties) { Function = function; } + public new string Id => _id ?? default; + public InternalRunStepDetailsToolCallsFunctionObjectFunction Function { get; } } } diff --git a/.dotnet/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneChatRequestInput.Serialization.cs similarity index 71% rename from .dotnet/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs rename to .dotnet/src/Generated/Models/InternalTodoFineTuneChatRequestInput.Serialization.cs index 2f5a99d7b..ce3cb7ed7 100644 --- a/.dotnet/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneChatRequestInput.Serialization.cs @@ -12,9 +12,9 @@ namespace OpenAI.FineTuning { - internal partial class InternalFinetuneChatRequestInput : IJsonModel + internal partial class InternalTodoFineTuneChatRequestInput : IJsonModel { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -23,10 +23,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, M protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(InternalTodoFineTuneChatRequestInput)} does not support writing '{format}' format."); } if (Optional.IsCollectionDefined(Messages) && _additionalBinaryDataProperties?.ContainsKey("messages") != true) { @@ -96,20 +96,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalFinetuneChatRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + InternalTodoFineTuneChatRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual InternalFinetuneChatRequestInput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual InternalTodoFineTuneChatRequestInput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(InternalTodoFineTuneChatRequestInput)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFinetuneChatRequestInput(document.RootElement, options); + return DeserializeInternalTodoFineTuneChatRequestInput(document.RootElement, options); } - internal static InternalFinetuneChatRequestInput DeserializeInternalFinetuneChatRequestInput(JsonElement element, ModelReaderWriterOptions options) + internal static InternalTodoFineTuneChatRequestInput DeserializeInternalTodoFineTuneChatRequestInput(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -185,56 +185,56 @@ internal static InternalFinetuneChatRequestInput DeserializeInternalFinetuneChat additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalFinetuneChatRequestInput(messages ?? new ChangeTrackingList(), tools ?? new ChangeTrackingList(), parallelToolCalls, functions ?? new ChangeTrackingList(), additionalBinaryDataProperties); + return new InternalTodoFineTuneChatRequestInput(messages ?? new ChangeTrackingList(), tools ?? new ChangeTrackingList(), parallelToolCalls, functions ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalTodoFineTuneChatRequestInput)} does not support writing '{options.Format}' format."); } } - InternalFinetuneChatRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + InternalTodoFineTuneChatRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual InternalFinetuneChatRequestInput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual InternalTodoFineTuneChatRequestInput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalFinetuneChatRequestInput(document.RootElement, options); + return DeserializeInternalTodoFineTuneChatRequestInput(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalTodoFineTuneChatRequestInput)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalFinetuneChatRequestInput internalFinetuneChatRequestInput) + public static implicit operator BinaryContent(InternalTodoFineTuneChatRequestInput internalTodoFineTuneChatRequestInput) { - if (internalFinetuneChatRequestInput == null) + if (internalTodoFineTuneChatRequestInput == null) { return null; } - return BinaryContent.Create(internalFinetuneChatRequestInput, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(internalTodoFineTuneChatRequestInput, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalFinetuneChatRequestInput(ClientResult result) + public static explicit operator InternalTodoFineTuneChatRequestInput(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalFinetuneChatRequestInput(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeInternalTodoFineTuneChatRequestInput(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/InternalFinetuneChatRequestInput.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneChatRequestInput.cs similarity index 76% rename from .dotnet/src/Generated/Models/InternalFinetuneChatRequestInput.cs rename to .dotnet/src/Generated/Models/InternalTodoFineTuneChatRequestInput.cs index 6588ee146..165135c4c 100644 --- a/.dotnet/src/Generated/Models/InternalFinetuneChatRequestInput.cs +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneChatRequestInput.cs @@ -9,18 +9,18 @@ namespace OpenAI.FineTuning { - internal partial class InternalFinetuneChatRequestInput + internal partial class InternalTodoFineTuneChatRequestInput { private protected IDictionary _additionalBinaryDataProperties; - public InternalFinetuneChatRequestInput() + public InternalTodoFineTuneChatRequestInput() { Messages = new ChangeTrackingList(); Tools = new ChangeTrackingList(); Functions = new ChangeTrackingList(); } - internal InternalFinetuneChatRequestInput(IList messages, IList tools, bool? parallelToolCalls, IList functions, IDictionary additionalBinaryDataProperties) + internal InternalTodoFineTuneChatRequestInput(IList messages, IList tools, bool? parallelToolCalls, IList functions, IDictionary additionalBinaryDataProperties) { Messages = messages; Tools = tools; diff --git a/.dotnet/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneCompletionRequestInput.Serialization.cs similarity index 56% rename from .dotnet/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs rename to .dotnet/src/Generated/Models/InternalTodoFineTuneCompletionRequestInput.Serialization.cs index 30c684544..ca2640d3d 100644 --- a/.dotnet/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneCompletionRequestInput.Serialization.cs @@ -11,9 +11,9 @@ namespace OpenAI.FineTuning { - internal partial class InternalFinetuneCompletionRequestInput : IJsonModel + internal partial class InternalTodoFineTuneCompletionRequestInput : IJsonModel { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -22,10 +22,10 @@ void IJsonModel.Write(Utf8JsonWriter wri protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(InternalTodoFineTuneCompletionRequestInput)} does not support writing '{format}' format."); } if (Optional.IsDefined(Prompt) && _additionalBinaryDataProperties?.ContainsKey("prompt") != true) { @@ -58,20 +58,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalFinetuneCompletionRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + InternalTodoFineTuneCompletionRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual InternalFinetuneCompletionRequestInput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual InternalTodoFineTuneCompletionRequestInput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(InternalTodoFineTuneCompletionRequestInput)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement, options); + return DeserializeInternalTodoFineTuneCompletionRequestInput(document.RootElement, options); } - internal static InternalFinetuneCompletionRequestInput DeserializeInternalFinetuneCompletionRequestInput(JsonElement element, ModelReaderWriterOptions options) + internal static InternalTodoFineTuneCompletionRequestInput DeserializeInternalTodoFineTuneCompletionRequestInput(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -97,56 +97,56 @@ internal static InternalFinetuneCompletionRequestInput DeserializeInternalFinetu additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalFinetuneCompletionRequestInput(prompt, completion, additionalBinaryDataProperties); + return new InternalTodoFineTuneCompletionRequestInput(prompt, completion, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalTodoFineTuneCompletionRequestInput)} does not support writing '{options.Format}' format."); } } - InternalFinetuneCompletionRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + InternalTodoFineTuneCompletionRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual InternalFinetuneCompletionRequestInput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual InternalTodoFineTuneCompletionRequestInput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement, options); + return DeserializeInternalTodoFineTuneCompletionRequestInput(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalTodoFineTuneCompletionRequestInput)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalFinetuneCompletionRequestInput internalFinetuneCompletionRequestInput) + public static implicit operator BinaryContent(InternalTodoFineTuneCompletionRequestInput internalTodoFineTuneCompletionRequestInput) { - if (internalFinetuneCompletionRequestInput == null) + if (internalTodoFineTuneCompletionRequestInput == null) { return null; } - return BinaryContent.Create(internalFinetuneCompletionRequestInput, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(internalTodoFineTuneCompletionRequestInput, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalFinetuneCompletionRequestInput(ClientResult result) + public static explicit operator InternalTodoFineTuneCompletionRequestInput(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeInternalTodoFineTuneCompletionRequestInput(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneCompletionRequestInput.cs similarity index 71% rename from .dotnet/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs rename to .dotnet/src/Generated/Models/InternalTodoFineTuneCompletionRequestInput.cs index 77224a7f9..f7292b95b 100644 --- a/.dotnet/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneCompletionRequestInput.cs @@ -7,15 +7,15 @@ namespace OpenAI.FineTuning { - internal partial class InternalFinetuneCompletionRequestInput + internal partial class InternalTodoFineTuneCompletionRequestInput { private protected IDictionary _additionalBinaryDataProperties; - public InternalFinetuneCompletionRequestInput() + public InternalTodoFineTuneCompletionRequestInput() { } - internal InternalFinetuneCompletionRequestInput(string prompt, string completion, IDictionary additionalBinaryDataProperties) + internal InternalTodoFineTuneCompletionRequestInput(string prompt, string completion, IDictionary additionalBinaryDataProperties) { Prompt = prompt; Completion = completion; diff --git a/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethod.Serialization.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethod.Serialization.cs new file mode 100644 index 000000000..5c6d3fbeb --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethod.Serialization.cs @@ -0,0 +1,145 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.FineTuning +{ + internal partial class InternalTodoFineTuneDPOMethod : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTodoFineTuneDPOMethod)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Hyperparameters) && _additionalBinaryDataProperties?.ContainsKey("hyperparameters") != true) + { + writer.WritePropertyName("hyperparameters"u8); + writer.WriteObjectValue(Hyperparameters, options); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalTodoFineTuneDPOMethod IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalTodoFineTuneDPOMethod JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTodoFineTuneDPOMethod)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalTodoFineTuneDPOMethod(document.RootElement, options); + } + + internal static InternalTodoFineTuneDPOMethod DeserializeInternalTodoFineTuneDPOMethod(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalTodoFineTuneDPOMethodHyperparameters hyperparameters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("hyperparameters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + hyperparameters = InternalTodoFineTuneDPOMethodHyperparameters.DeserializeInternalTodoFineTuneDPOMethodHyperparameters(prop.Value, options); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalTodoFineTuneDPOMethod(hyperparameters, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalTodoFineTuneDPOMethod)} does not support writing '{options.Format}' format."); + } + } + + InternalTodoFineTuneDPOMethod IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalTodoFineTuneDPOMethod PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalTodoFineTuneDPOMethod(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalTodoFineTuneDPOMethod)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalTodoFineTuneDPOMethod internalTodoFineTuneDPOMethod) + { + if (internalTodoFineTuneDPOMethod == null) + { + return null; + } + return BinaryContent.Create(internalTodoFineTuneDPOMethod, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalTodoFineTuneDPOMethod(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalTodoFineTuneDPOMethod(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethod.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethod.cs new file mode 100644 index 000000000..15ee9dbcd --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethod.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.FineTuning +{ + internal partial class InternalTodoFineTuneDPOMethod + { + private protected IDictionary _additionalBinaryDataProperties; + + public InternalTodoFineTuneDPOMethod() + { + } + + internal InternalTodoFineTuneDPOMethod(InternalTodoFineTuneDPOMethodHyperparameters hyperparameters, IDictionary additionalBinaryDataProperties) + { + Hyperparameters = hyperparameters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public InternalTodoFineTuneDPOMethodHyperparameters Hyperparameters { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethodHyperparameters.Serialization.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethodHyperparameters.Serialization.cs new file mode 100644 index 000000000..8cb18f1bf --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethodHyperparameters.Serialization.cs @@ -0,0 +1,218 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.FineTuning +{ + internal partial class InternalTodoFineTuneDPOMethodHyperparameters : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTodoFineTuneDPOMethodHyperparameters)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Beta) && _additionalBinaryDataProperties?.ContainsKey("beta") != true) + { + writer.WritePropertyName("beta"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Beta); +#else + using (JsonDocument document = JsonDocument.Parse(Beta)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(BatchSize) && _additionalBinaryDataProperties?.ContainsKey("batch_size") != true) + { + writer.WritePropertyName("batch_size"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(BatchSize); +#else + using (JsonDocument document = JsonDocument.Parse(BatchSize)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(LearningRateMultiplier) && _additionalBinaryDataProperties?.ContainsKey("learning_rate_multiplier") != true) + { + writer.WritePropertyName("learning_rate_multiplier"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(LearningRateMultiplier); +#else + using (JsonDocument document = JsonDocument.Parse(LearningRateMultiplier)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(NEpochs) && _additionalBinaryDataProperties?.ContainsKey("n_epochs") != true) + { + writer.WritePropertyName("n_epochs"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(NEpochs); +#else + using (JsonDocument document = JsonDocument.Parse(NEpochs)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalTodoFineTuneDPOMethodHyperparameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalTodoFineTuneDPOMethodHyperparameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTodoFineTuneDPOMethodHyperparameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalTodoFineTuneDPOMethodHyperparameters(document.RootElement, options); + } + + internal static InternalTodoFineTuneDPOMethodHyperparameters DeserializeInternalTodoFineTuneDPOMethodHyperparameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData beta = default; + BinaryData batchSize = default; + BinaryData learningRateMultiplier = default; + BinaryData nEpochs = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("beta"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + beta = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("batch_size"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + batchSize = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("learning_rate_multiplier"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + learningRateMultiplier = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("n_epochs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nEpochs = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalTodoFineTuneDPOMethodHyperparameters(beta, batchSize, learningRateMultiplier, nEpochs, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalTodoFineTuneDPOMethodHyperparameters)} does not support writing '{options.Format}' format."); + } + } + + InternalTodoFineTuneDPOMethodHyperparameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalTodoFineTuneDPOMethodHyperparameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalTodoFineTuneDPOMethodHyperparameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalTodoFineTuneDPOMethodHyperparameters)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalTodoFineTuneDPOMethodHyperparameters internalTodoFineTuneDPOMethodHyperparameters) + { + if (internalTodoFineTuneDPOMethodHyperparameters == null) + { + return null; + } + return BinaryContent.Create(internalTodoFineTuneDPOMethodHyperparameters, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalTodoFineTuneDPOMethodHyperparameters(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalTodoFineTuneDPOMethodHyperparameters(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethodHyperparameters.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethodHyperparameters.cs new file mode 100644 index 000000000..2d0fc8cd5 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneDPOMethodHyperparameters.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.FineTuning +{ + internal partial class InternalTodoFineTuneDPOMethodHyperparameters + { + private protected IDictionary _additionalBinaryDataProperties; + + public InternalTodoFineTuneDPOMethodHyperparameters() + { + } + + internal InternalTodoFineTuneDPOMethodHyperparameters(BinaryData beta, BinaryData batchSize, BinaryData learningRateMultiplier, BinaryData nEpochs, IDictionary additionalBinaryDataProperties) + { + Beta = beta; + BatchSize = batchSize; + LearningRateMultiplier = learningRateMultiplier; + NEpochs = nEpochs; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public BinaryData Beta { get; set; } + + public BinaryData BatchSize { get; set; } + + public BinaryData LearningRateMultiplier { get; set; } + + public BinaryData NEpochs { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalTodoFineTuneMethod.Serialization.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneMethod.Serialization.cs new file mode 100644 index 000000000..222f56369 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneMethod.Serialization.cs @@ -0,0 +1,175 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.FineTuning +{ + internal partial class InternalTodoFineTuneMethod : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTodoFineTuneMethod)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Type) && _additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsDefined(Supervised) && _additionalBinaryDataProperties?.ContainsKey("supervised") != true) + { + writer.WritePropertyName("supervised"u8); + writer.WriteObjectValue(Supervised, options); + } + if (Optional.IsDefined(Dpo) && _additionalBinaryDataProperties?.ContainsKey("dpo") != true) + { + writer.WritePropertyName("dpo"u8); + writer.WriteObjectValue(Dpo, options); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalTodoFineTuneMethod IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalTodoFineTuneMethod JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTodoFineTuneMethod)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalTodoFineTuneMethod(document.RootElement, options); + } + + internal static InternalTodoFineTuneMethod DeserializeInternalTodoFineTuneMethod(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalTodoFineTuneMethodType? @type = default; + InternalTodoFineTuneSupervisedMethod supervised = default; + InternalTodoFineTuneDPOMethod dpo = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @type = new InternalTodoFineTuneMethodType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("supervised"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + supervised = InternalTodoFineTuneSupervisedMethod.DeserializeInternalTodoFineTuneSupervisedMethod(prop.Value, options); + continue; + } + if (prop.NameEquals("dpo"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dpo = InternalTodoFineTuneDPOMethod.DeserializeInternalTodoFineTuneDPOMethod(prop.Value, options); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalTodoFineTuneMethod(@type, supervised, dpo, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalTodoFineTuneMethod)} does not support writing '{options.Format}' format."); + } + } + + InternalTodoFineTuneMethod IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalTodoFineTuneMethod PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalTodoFineTuneMethod(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalTodoFineTuneMethod)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalTodoFineTuneMethod internalTodoFineTuneMethod) + { + if (internalTodoFineTuneMethod == null) + { + return null; + } + return BinaryContent.Create(internalTodoFineTuneMethod, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalTodoFineTuneMethod(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalTodoFineTuneMethod(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalTodoFineTuneMethod.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneMethod.cs new file mode 100644 index 000000000..f3c742bca --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneMethod.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.FineTuning +{ + internal partial class InternalTodoFineTuneMethod + { + private protected IDictionary _additionalBinaryDataProperties; + + public InternalTodoFineTuneMethod() + { + } + + internal InternalTodoFineTuneMethod(InternalTodoFineTuneMethodType? @type, InternalTodoFineTuneSupervisedMethod supervised, InternalTodoFineTuneDPOMethod dpo, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Supervised = supervised; + Dpo = dpo; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public InternalTodoFineTuneMethodType? Type { get; set; } + + public InternalTodoFineTuneSupervisedMethod Supervised { get; set; } + + public InternalTodoFineTuneDPOMethod Dpo { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalTodoFineTuneMethodType.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneMethodType.cs new file mode 100644 index 000000000..9d4bff177 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneMethodType.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.FineTuning +{ + internal readonly partial struct InternalTodoFineTuneMethodType : IEquatable + { + private readonly string _value; + private const string SupervisedValue = "supervised"; + private const string DpoValue = "dpo"; + + public InternalTodoFineTuneMethodType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalTodoFineTuneMethodType Supervised { get; } = new InternalTodoFineTuneMethodType(SupervisedValue); + + public static InternalTodoFineTuneMethodType Dpo { get; } = new InternalTodoFineTuneMethodType(DpoValue); + + public static bool operator ==(InternalTodoFineTuneMethodType left, InternalTodoFineTuneMethodType right) => left.Equals(right); + + public static bool operator !=(InternalTodoFineTuneMethodType left, InternalTodoFineTuneMethodType right) => !left.Equals(right); + + public static implicit operator InternalTodoFineTuneMethodType(string value) => new InternalTodoFineTuneMethodType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalTodoFineTuneMethodType other && Equals(other); + + public bool Equals(InternalTodoFineTuneMethodType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalTodoFineTuneSupervisedMethod.Serialization.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneSupervisedMethod.Serialization.cs new file mode 100644 index 000000000..eac268c8b --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneSupervisedMethod.Serialization.cs @@ -0,0 +1,145 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.FineTuning +{ + internal partial class InternalTodoFineTuneSupervisedMethod : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTodoFineTuneSupervisedMethod)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Hyperparameters) && _additionalBinaryDataProperties?.ContainsKey("hyperparameters") != true) + { + writer.WritePropertyName("hyperparameters"u8); + writer.WriteObjectValue(Hyperparameters, options); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalTodoFineTuneSupervisedMethod IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalTodoFineTuneSupervisedMethod JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTodoFineTuneSupervisedMethod)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalTodoFineTuneSupervisedMethod(document.RootElement, options); + } + + internal static InternalTodoFineTuneSupervisedMethod DeserializeInternalTodoFineTuneSupervisedMethod(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalFineTuneSupervisedMethodHyperparameters hyperparameters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("hyperparameters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + hyperparameters = InternalFineTuneSupervisedMethodHyperparameters.DeserializeInternalFineTuneSupervisedMethodHyperparameters(prop.Value, options); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalTodoFineTuneSupervisedMethod(hyperparameters, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalTodoFineTuneSupervisedMethod)} does not support writing '{options.Format}' format."); + } + } + + InternalTodoFineTuneSupervisedMethod IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalTodoFineTuneSupervisedMethod PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalTodoFineTuneSupervisedMethod(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalTodoFineTuneSupervisedMethod)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalTodoFineTuneSupervisedMethod internalTodoFineTuneSupervisedMethod) + { + if (internalTodoFineTuneSupervisedMethod == null) + { + return null; + } + return BinaryContent.Create(internalTodoFineTuneSupervisedMethod, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalTodoFineTuneSupervisedMethod(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalTodoFineTuneSupervisedMethod(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalTodoFineTuneSupervisedMethod.cs b/.dotnet/src/Generated/Models/InternalTodoFineTuneSupervisedMethod.cs new file mode 100644 index 000000000..3cc8531a5 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalTodoFineTuneSupervisedMethod.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.FineTuning +{ + internal partial class InternalTodoFineTuneSupervisedMethod + { + private protected IDictionary _additionalBinaryDataProperties; + + public InternalTodoFineTuneSupervisedMethod() + { + } + + internal InternalTodoFineTuneSupervisedMethod(InternalFineTuneSupervisedMethodHyperparameters hyperparameters, IDictionary additionalBinaryDataProperties) + { + Hyperparameters = hyperparameters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public InternalFineTuneSupervisedMethodHyperparameters Hyperparameters { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/OpenAIFileCollection.Serialization.cs b/.dotnet/src/Generated/Models/OpenAIFileCollection.Serialization.cs index 4c04572bb..78729d5de 100644 --- a/.dotnet/src/Generated/Models/OpenAIFileCollection.Serialization.cs +++ b/.dotnet/src/Generated/Models/OpenAIFileCollection.Serialization.cs @@ -22,7 +22,22 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("object") != true) { writer.WritePropertyName("object"u8); - writer.WriteStringValue(this.Object.ToString()); + writer.WriteStringValue(this.Object); + } + if (_additionalBinaryDataProperties?.ContainsKey("first_id") != true) + { + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + } + if (_additionalBinaryDataProperties?.ContainsKey("last_id") != true) + { + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + } + if (_additionalBinaryDataProperties?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); } if (true && _additionalBinaryDataProperties != null) { diff --git a/.dotnet/src/Generated/Models/ResponseConversationSelection.cs b/.dotnet/src/Generated/Models/ResponseConversationSelection.cs new file mode 100644 index 000000000..0fbfb42a4 --- /dev/null +++ b/.dotnet/src/Generated/Models/ResponseConversationSelection.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + public readonly partial struct ResponseConversationSelection : IEquatable + { + private readonly string _value; + private const string AutoValue = "auto"; + private const string NoneValue = "none"; + + public ResponseConversationSelection(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static ResponseConversationSelection Auto { get; } = new ResponseConversationSelection(AutoValue); + + public static ResponseConversationSelection None { get; } = new ResponseConversationSelection(NoneValue); + + public static bool operator ==(ResponseConversationSelection left, ResponseConversationSelection right) => left.Equals(right); + + public static bool operator !=(ResponseConversationSelection left, ResponseConversationSelection right) => !left.Equals(right); + + public static implicit operator ResponseConversationSelection(string value) => new ResponseConversationSelection(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResponseConversationSelection other && Equals(other); + + public bool Equals(ResponseConversationSelection other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.Serialization.cs b/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.Serialization.cs index ff4b07f50..f66c049a2 100644 --- a/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.Serialization.cs +++ b/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.Serialization.cs @@ -89,6 +89,10 @@ internal static RunStepFileSearchResultContent DeserializeRunStepFileSearchResul } if (prop.NameEquals("type"u8)) { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } kind = prop.Value.GetString().ToRunStepFileSearchResultContentKind(); continue; } diff --git a/.dotnet/src/Generated/Models/RunStepToolCall.cs b/.dotnet/src/Generated/Models/RunStepToolCall.cs index a1ff98139..1fee31ebd 100644 --- a/.dotnet/src/Generated/Models/RunStepToolCall.cs +++ b/.dotnet/src/Generated/Models/RunStepToolCall.cs @@ -10,6 +10,7 @@ namespace OpenAI.Assistants public abstract partial class RunStepToolCall { private protected IDictionary _additionalBinaryDataProperties; + private protected string _id; private protected RunStepToolCall(string id, Assistants.RunStepToolCallKind kind) { diff --git a/.dotnet/src/Generated/Models/UnknownRealtimeResponseStatusDetails.Serialization.cs b/.dotnet/src/Generated/Models/UnknownRealtimeResponseStatusDetails.Serialization.cs deleted file mode 100644 index 21fc7644a..000000000 --- a/.dotnet/src/Generated/Models/UnknownRealtimeResponseStatusDetails.Serialization.cs +++ /dev/null @@ -1,105 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.RealtimeConversation -{ - internal partial class UnknownRealtimeResponseStatusDetails : IJsonModel - { - internal UnknownRealtimeResponseStatusDetails() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ConversationStatusDetails)} does not support writing '{format}' format."); - } - base.JsonModelWriteCore(writer, options); - } - - ConversationStatusDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - protected override ConversationStatusDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ConversationStatusDetails)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeConversationStatusDetails(document.RootElement, options); - } - - internal static UnknownRealtimeResponseStatusDetails DeserializeUnknownRealtimeResponseStatusDetails(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ConversationStatus statusKind = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - statusKind = new ConversationStatus(prop.Value.GetString()); - continue; - } - if (true) - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new UnknownRealtimeResponseStatusDetails(statusKind, additionalBinaryDataProperties); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ConversationStatusDetails)} does not support writing '{options.Format}' format."); - } - } - - ConversationStatusDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - protected override ConversationStatusDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeConversationStatusDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ConversationStatusDetails)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/.dotnet/src/Generated/Models/UnknownRealtimeResponseStatusDetails.cs b/.dotnet/src/Generated/Models/UnknownRealtimeResponseStatusDetails.cs deleted file mode 100644 index 0bbcb1f2a..000000000 --- a/.dotnet/src/Generated/Models/UnknownRealtimeResponseStatusDetails.cs +++ /dev/null @@ -1,16 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace OpenAI.RealtimeConversation -{ - internal partial class UnknownRealtimeResponseStatusDetails : ConversationStatusDetails - { - internal UnknownRealtimeResponseStatusDetails(ConversationStatus statusKind, IDictionary additionalBinaryDataProperties) : base(statusKind != default ? statusKind : "unknown", additionalBinaryDataProperties) - { - } - } -} diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index 096e66a75..5d8813093 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -419,7 +419,7 @@ public static ThreadDeletionResult ThreadDeletionResult(bool deleted = default, return new ThreadDeletionResult(deleted, threadId, @object, additionalBinaryDataProperties: null); } - public static ConversationSessionOptions ConversationSessionOptions(string instructions = default, ConversationVoice? voice = default, ConversationAudioFormat? inputAudioFormat = default, ConversationAudioFormat? outputAudioFormat = default, IEnumerable tools = default, float? temperature = default, ConversationTurnDetectionOptions turnDetectionOptions = default, ConversationInputTranscriptionOptions inputTranscriptionOptions = default, IEnumerable internalModalities = default, BinaryData internalToolChoice = default, BinaryData maxResponseOutputTokens = default) + public static ConversationSessionOptions ConversationSessionOptions(string instructions = default, ConversationVoice? voice = default, ConversationAudioFormat? inputAudioFormat = default, ConversationAudioFormat? outputAudioFormat = default, IEnumerable tools = default, float? temperature = default, InternalRealtimeRequestSessionModel? model = default, ConversationTurnDetectionOptions turnDetectionOptions = default, ConversationInputTranscriptionOptions inputTranscriptionOptions = default, IEnumerable internalModalities = default, BinaryData internalToolChoice = default, BinaryData maxResponseOutputTokens = default) { tools ??= new ChangeTrackingList(); internalModalities ??= new ChangeTrackingList(); @@ -431,6 +431,7 @@ public static ConversationSessionOptions ConversationSessionOptions(string instr outputAudioFormat, tools?.ToList(), temperature, + model, turnDetectionOptions, inputTranscriptionOptions, internalModalities?.ToList(), @@ -475,6 +476,28 @@ public static ConversationContentPart ConversationContentPart(string kind = defa return new UnknownRealtimeContentPart(new ConversationContentPartKind(kind), additionalBinaryDataProperties: null); } + public static ConversationResponseOptions ConversationResponseOptions(string instructions = default, ConversationVoice? voice = default, ConversationAudioFormat? outputAudioFormat = default, IEnumerable tools = default, float? temperature = default, IDictionary metadata = default, ResponseConversationSelection? conversationSelection = default, IEnumerable overrideItems = default, IEnumerable internalModalities = default, BinaryData internalToolChoice = default, BinaryData maxResponseOutputTokens = default) + { + tools ??= new ChangeTrackingList(); + metadata ??= new ChangeTrackingDictionary(); + overrideItems ??= new ChangeTrackingList(); + internalModalities ??= new ChangeTrackingList(); + + return new ConversationResponseOptions( + instructions, + voice, + outputAudioFormat, + tools?.ToList(), + temperature, + metadata, + conversationSelection, + overrideItems?.ToList(), + internalModalities?.ToList(), + internalToolChoice, + maxResponseOutputTokens, + additionalBinaryDataProperties: null); + } + public static ConversationUpdate ConversationUpdate(string eventId = default, string kind = default) { @@ -577,13 +600,13 @@ public static ConversationResponseStartedUpdate ConversationResponseStartedUpdat return new ConversationResponseStartedUpdate(eventId, RealtimeConversation.ConversationUpdateKind.ResponseStarted, additionalBinaryDataProperties: null, internalResponse); } - public static ConversationStatusDetails ConversationStatusDetails(string statusKind = default) + public static ConversationStatusDetails ConversationStatusDetails(ConversationStatus statusKind = default, ConversationIncompleteReason? incompleteReason = default, InternalRealtimeResponseStatusDetailsError error = default) { - return new UnknownRealtimeResponseStatusDetails(new ConversationStatus(statusKind), additionalBinaryDataProperties: null); + return new ConversationStatusDetails(statusKind, incompleteReason, error, additionalBinaryDataProperties: null); } - public static ConversationTokenUsage ConversationTokenUsage(int totalTokens = default, int inputTokens = default, int outputTokens = default, ConversationInputTokenUsageDetails inputTokenDetails = default, ConversationOutputTokenUsageDetails outputTokenDetails = default) + public static ConversationTokenUsage ConversationTokenUsage(int? totalTokens = default, int? inputTokens = default, int? outputTokens = default, ConversationInputTokenUsageDetails inputTokenDetails = default, ConversationOutputTokenUsageDetails outputTokenDetails = default) { return new ConversationTokenUsage( @@ -595,16 +618,16 @@ public static ConversationTokenUsage ConversationTokenUsage(int totalTokens = de additionalBinaryDataProperties: null); } - public static ConversationInputTokenUsageDetails ConversationInputTokenUsageDetails(int cachedTokens = default, int textTokens = default, int audioTokens = default) + public static ConversationInputTokenUsageDetails ConversationInputTokenUsageDetails(int audioTokenCount = default, int cachedTokenCount = default, int textTokenCount = default) { - return new ConversationInputTokenUsageDetails(cachedTokens, textTokens, audioTokens, additionalBinaryDataProperties: null); + return new ConversationInputTokenUsageDetails(audioTokenCount, cachedTokenCount, textTokenCount, additionalBinaryDataProperties: null); } - public static ConversationOutputTokenUsageDetails ConversationOutputTokenUsageDetails(int textTokens = default, int audioTokens = default) + public static ConversationOutputTokenUsageDetails ConversationOutputTokenUsageDetails(int textTokenCount = default, int audioTokenCount = default) { - return new ConversationOutputTokenUsageDetails(textTokens, audioTokens, additionalBinaryDataProperties: null); + return new ConversationOutputTokenUsageDetails(textTokenCount, audioTokenCount, additionalBinaryDataProperties: null); } public static ConversationResponseFinishedUpdate ConversationResponseFinishedUpdate(string eventId = default, InternalRealtimeResponse internalResponse = default) @@ -822,11 +845,17 @@ public static ImageVariationOptions ImageVariationOptions(InternalCreateImageVar additionalBinaryDataProperties: null); } - public static OpenAIFileCollection OpenAIFileCollection(IEnumerable data = default, InternalListFilesResponseObject @object = default) + public static OpenAIFileCollection OpenAIFileCollection(IEnumerable data = default, string @object = default, string firstId = default, string lastId = default, bool hasMore = default) { data ??= new ChangeTrackingList(); - return new OpenAIFileCollection(data?.ToList(), @object, serializedAdditionalRawData: null); + return new OpenAIFileCollection( + data?.ToList(), + @object, + firstId, + lastId, + hasMore, + serializedAdditionalRawData: null); } public static FileDeletionResult FileDeletionResult(bool deleted = default, string fileId = default, InternalDeleteFileResponseObject @object = default) @@ -878,10 +907,10 @@ public static ChatTokenUsage ChatTokenUsage(int outputTokenCount = default, int additionalBinaryDataProperties: null); } - public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default, int audioTokenCount = default) + public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default, int audioTokenCount = default, int predictionAcceptedTokenCount = default, int predictionRejectedTokenCount = default) { - return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, additionalBinaryDataProperties: null); + return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, predictionAcceptedTokenCount, predictionRejectedTokenCount, additionalBinaryDataProperties: null); } public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = default, int cachedTokenCount = default) @@ -890,7 +919,7 @@ public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTok return new ChatInputTokenUsageDetails(audioTokenCount, cachedTokenCount, additionalBinaryDataProperties: null); } - public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalty = default, float? presencePenalty = default, ChatResponseFormat responseFormat = default, float? temperature = default, float? topP = default, IEnumerable tools = default, IEnumerable messages = default, InternalCreateChatCompletionRequestModel model = default, int? n = default, bool? stream = default, InternalChatCompletionStreamOptions streamOptions = default, bool? includeLogProbabilities = default, int? topLogProbabilityCount = default, IEnumerable stopSequences = default, IDictionary logitBiases = default, ChatToolChoice toolChoice = default, ChatFunctionChoice functionChoice = default, bool? allowParallelToolCalls = default, string endUserId = default, long? seed = default, int? deprecatedMaxTokens = default, int? maxOutputTokenCount = default, IEnumerable functions = default, IDictionary metadata = default, bool? storedOutputEnabled = default, InternalCreateChatCompletionRequestServiceTier? serviceTier = default, IEnumerable internalModalities = default, ChatAudioOptions audioOptions = default) + public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalty = default, float? presencePenalty = default, ChatResponseFormat responseFormat = default, float? temperature = default, float? topP = default, IEnumerable tools = default, IEnumerable messages = default, InternalCreateChatCompletionRequestModel model = default, int? n = default, bool? stream = default, InternalChatCompletionStreamOptions streamOptions = default, bool? includeLogProbabilities = default, int? topLogProbabilityCount = default, IEnumerable stopSequences = default, IDictionary logitBiases = default, ChatToolChoice toolChoice = default, ChatFunctionChoice functionChoice = default, bool? allowParallelToolCalls = default, string endUserId = default, long? seed = default, int? deprecatedMaxTokens = default, int? maxOutputTokenCount = default, IEnumerable functions = default, IDictionary metadata = default, bool? storedOutputEnabled = default, ChatReasoningEffort? reasoningEffort = default, ChatMessageContent predictedContent = default, InternalCreateChatCompletionRequestServiceTier? serviceTier = default, IEnumerable internalModalities = default, ChatAudioOptions audioOptions = default) { tools ??= new ChangeTrackingList(); messages ??= new ChangeTrackingList(); @@ -926,6 +955,8 @@ public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalt functions?.ToList(), metadata, storedOutputEnabled, + reasoningEffort, + predictedContent, serviceTier, internalModalities?.ToList(), audioOptions, @@ -944,6 +975,12 @@ public static SystemChatMessage SystemChatMessage(ChatMessageContent content = d return new SystemChatMessage(content, Chat.ChatMessageRole.System, additionalBinaryDataProperties: null, participantName); } + public static DeveloperChatMessage DeveloperChatMessage(ChatMessageContent content = default, string participantName = default) + { + + return new DeveloperChatMessage(content, Chat.ChatMessageRole.Developer, additionalBinaryDataProperties: null, participantName); + } + public static UserChatMessage UserChatMessage(ChatMessageContent content = default, string participantName = default) { diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index 3a6da8060..e014e555f 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -872,4 +872,57 @@ public async Task ReasoningTokensWork() Assert.That(completion.Usage.OutputTokenDetails?.ReasoningTokenCount, Is.GreaterThan(0)); Assert.That(completion.Usage.OutputTokenDetails?.ReasoningTokenCount, Is.LessThan(completion.Usage.OutputTokenCount)); } + + [Test] + public async Task PredictedOutputsWork() + { + ChatClient client = GetTestClient(TestScenario.Chat); + + ChatCompletionOptions options = new() + { + PredictedContent = + [ + ChatMessageContentPart.CreateTextPart(""" + { + "feature_name": "test_feature", + "enabled": true + } + """.ReplaceLineEndings("\n")), + ], + }; + + ChatMessage message = ChatMessage.CreateUserMessage(""" + Modify the following input to enable the feature. Only respond with the JSON and include no other text. + + { + "feature_name": "test_feature", + "enabled": false + } + """.ReplaceLineEndings("\n")); + + ChatCompletion completion = await client.CompleteChatAsync([message], options); + + Assert.That(completion.Usage.OutputTokenDetails.PredictionAcceptedTokenCount, Is.GreaterThan(0)); + } + + [Test] + public async Task O1DeveloperMessagesWork() + { + List messages = + [ + ChatMessage.CreateDeveloperMessage("When asked questions about naval topics, you always talk like a pirate."), + ChatMessage.CreateUserMessage("What's the best route to sail from San Francisco to New York?") + ]; + + ChatCompletionOptions options = new() + { + ReasoningEffort = ChatReasoningEffort.Low, + }; + + ChatClient client = GetTestClient(TestScenario.Chat, "o1"); + ChatCompletion completion = await client.CompleteChatAsync(messages, options); + + List expectedPossibles = ["arr", "matey", "hearty", "avast"]; + Assert.That(expectedPossibles.Any(expected => completion.Content[0].Text.ToLower().Contains(expected))); + } } diff --git a/.dotnet/tests/RealtimeConversation/ConversationTests.cs b/.dotnet/tests/RealtimeConversation/ConversationTests.cs index a38fdecfc..e572d29bc 100644 --- a/.dotnet/tests/RealtimeConversation/ConversationTests.cs +++ b/.dotnet/tests/RealtimeConversation/ConversationTests.cs @@ -37,7 +37,7 @@ public async Task CanConfigureSession() }; await session.ConfigureSessionAsync(sessionOptions, CancellationToken); - ConversationSessionOptions responseOverrideOptions = new() + ConversationResponseOptions responseOverrideOptions = new() { ContentModalities = ConversationContentModalities.Text, }; @@ -527,6 +527,78 @@ public async Task CanAddItems() Assert.That(itemCreatedCount, Is.EqualTo(items.Count + 1)); } + [Test] + public async Task CanUseOutOfBandResponses() + { + RealtimeConversationClient client = GetTestClient(); + using RealtimeConversationSession session = await client.StartConversationSessionAsync(CancellationToken); + await session.AddItemAsync( + ConversationItem.CreateUserMessage(["Hello! My name is Bob."]), + cancellationToken: CancellationToken); + await session.StartResponseAsync( + new ConversationResponseOptions() + { + ConversationSelection = ResponseConversationSelection.None, + ContentModalities = ConversationContentModalities.Text, + OverrideItems = + { + ConversationItem.CreateUserMessage(["Can you tell me what my name is?"]), + }, + }, + CancellationToken); + + StringBuilder firstResponseBuilder = new(); + StringBuilder secondResponseBuilder = new(); + + int completedResponseCount = 0; + + await foreach (ConversationUpdate update in session.ReceiveUpdatesAsync(CancellationToken)) + { + if (update is ConversationSessionStartedUpdate sessionStartedUpdate) + { + Assert.That(sessionStartedUpdate.SessionId, Is.Not.Null.And.Not.Empty); + } + + if (update is ConversationItemStreamingPartDeltaUpdate deltaUpdate) + { + // First response (out of band) should be text, second (in-band) should be text + audio + if (completedResponseCount == 0) + { + firstResponseBuilder.Append(deltaUpdate.Text); + Assert.That(deltaUpdate.AudioTranscript, Is.Null.Or.Empty); + } + else + { + secondResponseBuilder.Append(deltaUpdate.AudioTranscript); + Assert.That(deltaUpdate.Text, Is.Null.Or.Empty); + } + } + + if (update is ConversationResponseFinishedUpdate responseFinishedUpdate) + { + completedResponseCount++; + Assert.That(responseFinishedUpdate.CreatedItems, Has.Count.GreaterThan(0)); + if (completedResponseCount == 1) + { + // Verify that an in-band response *does* have the information + _ = session.StartResponseAsync(CancellationToken); + } + else if (completedResponseCount == 2) + { + break; + } + } + } + + string firstResponse = firstResponseBuilder.ToString().ToLower(); + Assert.That(firstResponse, Is.Not.Null.And.Not.Empty); + Assert.That(firstResponse, Does.Not.Contain("bob")); + + string secondResponse = secondResponseBuilder.ToString().ToLower(); + Assert.That(secondResponse, Is.Not.Null.And.Not.Empty); + Assert.That(secondResponse, Does.Contain("bob")); + } + public enum TestAudioSendType { WithAudioStreamHelper, diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index 2f373d995..b16320a94 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -2936,6 +2936,36 @@ components: data: type: string format: binary + AdminApiKey: + type: object + properties: + object: + type: string + id: + type: string + name: + type: string + redacted_value: + type: string + value: + type: string + created_at: + type: integer + format: unixtime + owner: + type: object + properties: + type: + type: string + id: + type: string + name: + type: string + created_at: + type: integer + format: unixtime + role: + type: string AssistantObject: type: object required: @@ -2973,7 +3003,7 @@ components: description: The description of the assistant. The maximum length is 512 characters. model: type: string - description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. instructions: type: string nullable: true @@ -3151,7 +3181,7 @@ components: description: |- The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: '#/components/schemas/FileSearchRankingOptions' description: Overrides for the file search tool. @@ -3191,7 +3221,7 @@ components: - $ref: '#/components/schemas/ResponseFormatJsonObject' - $ref: '#/components/schemas/ResponseFormatJsonSchema' description: |- - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). @@ -3430,6 +3460,48 @@ components: type: string description: The project ID. description: The details for events with this `type`. + rate_limit.updated: + type: object + properties: + id: + type: string + description: The rate limit ID + changes_requested: + type: object + properties: + max_requests_per_1_minute: + type: integer + format: int32 + description: The maximum requests per minute. + max_tokens_per_1_minute: + type: integer + format: int32 + description: The maximum tokens per minute. + max_images_per_1_minute: + type: integer + format: int32 + description: The maximum images per minute. Only relevant for certain models. + max_audio_megabytes_per_1_minute: + type: integer + format: int32 + description: The maximum audio megabytes per minute. Only relevant for certain models. + max_requests_per_1_day: + type: integer + format: int32 + description: The maximum requests per day. Only relevant for certain models. + batch_1_day_max_input_tokens: + type: integer + format: int32 + description: The maximum batch input tokens per day. Only relevant for certain models. + description: The payload used to update the rate limits. + description: The details for events with this `type`. + rate_limit.deleted: + type: object + properties: + id: + type: string + description: The rate limit ID + description: The details for events with this `type`. service_account.created: type: object properties: @@ -3578,6 +3650,8 @@ components: - service_account.created - service_account.updated - service_account.deleted + - rate_limit.updated + - rate_limit.deleted - user.added - user.updated - user.deleted @@ -3985,11 +4059,39 @@ components: deprecated: true allOf: - $ref: '#/components/schemas/ChatCompletionRequestMessage' + description: Messages sent by the model in response to user messages. ChatCompletionRequestAssistantMessageContentPart: anyOf: - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartRefusal' x-oaiExpandable: true + ChatCompletionRequestDeveloperMessage: + type: object + required: + - content + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' + description: The contents of the developer message. + role: + type: string + enum: + - developer + description: The role of the messages author, in this case `developer`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, `developer` messages + replace the previous `system` messages. ChatCompletionRequestFunctionMessage: type: object required: @@ -4024,6 +4126,7 @@ components: propertyName: role mapping: system: '#/components/schemas/ChatCompletionRequestSystemMessage' + developer: '#/components/schemas/ChatCompletionRequestDeveloperMessage' user: '#/components/schemas/ChatCompletionRequestUserMessage' assistant: '#/components/schemas/ChatCompletionRequestAssistantMessage' tool: '#/components/schemas/ChatCompletionRequestToolMessage' @@ -4081,7 +4184,7 @@ components: - auto - low - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). default: auto required: - url @@ -4138,6 +4241,10 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. ChatCompletionRequestSystemMessageContentPart: type: object allOf: @@ -4196,6 +4303,9 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/ChatCompletionRequestMessage' + description: |- + Messages sent by an end user, containing prompts or additional context + information. ChatCompletionRequestUserMessageContentPart: anyOf: - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' @@ -4274,6 +4384,7 @@ components: type: string enum: - system + - developer - user - assistant - tool @@ -4519,6 +4630,12 @@ components: completion_tokens_details: type: object properties: + accepted_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that appeared in the completion. audio_tokens: type: integer format: int32 @@ -4527,9 +4644,15 @@ components: type: integer format: int32 description: Tokens generated by the model for reasoning. - required: - - audio_tokens - - reasoning_tokens + rejected_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that did not appear in the completion. However, like + reasoning tokens, these tokens are still counted in the total + completion tokens for purposes of billing, output, and context window + limits. description: Breakdown of tokens used in a completion. prompt_tokens_details: type: object @@ -4542,11 +4665,37 @@ components: type: integer format: int32 description: Cached tokens present in the prompt. - required: - - audio_tokens - - cached_tokens description: Breakdown of tokens used in the prompt. description: Usage statistics for the completion request. + CostsResult: + type: object + required: + - object + properties: + object: + type: string + enum: + - organization.costs.result + amount: + type: object + properties: + value: + type: number + format: float + description: The numeric value of the cost. + currency: + type: string + description: Lowercase ISO-4217 currency e.g. "usd" + description: The monetary value in its associated currency. + line_item: + type: string + nullable: true + description: When `group_by=line_item`, this field provides the line item of the grouped costs result. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of the grouped costs result. + description: The aggregated costs details of the specific time bucket. CreateAssistantRequest: type: object required: @@ -4558,6 +4707,7 @@ components: - type: string enum: - gpt-4o + - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - gpt-4o-mini @@ -4580,7 +4730,7 @@ components: - gpt-3.5-turbo-1106 - gpt-3.5-turbo-0125 - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. x-oaiTypeLabel: string name: type: string @@ -4730,17 +4880,21 @@ components: - type: string - type: string enum: + - o1 + - o1-2024-12-17 - o1-preview - o1-preview-2024-09-12 - o1-mini - o1-mini-2024-09-12 - gpt-4o + - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - gpt-4o-audio-preview - gpt-4o-audio-preview-2024-10-01 + - gpt-4o-audio-preview-2024-12-17 + - gpt-4o-mini-audio-preview + - gpt-4o-mini-audio-preview-2024-12-17 - chatgpt-4o-latest - gpt-4o-mini - gpt-4o-mini-2024-07-18 @@ -4763,15 +4917,31 @@ components: - gpt-3.5-turbo-1106 - gpt-3.5-turbo-0125 - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. + description: ID of the model to use. See the [model endpoint compatibility](/docs/models#model-endpoint-compatibility) table for details on which models work with the Chat API. x-oaiTypeLabel: string store: type: boolean nullable: true description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + Whether or not to store the output of this chat completion request for + use in our [model distillation](/docs/guides/distillation) or + [evals](/docs/guides/evals) products. default: false + reasoning_effort: + type: string + enum: + - low + - medium + - high + description: |- + **o1 models only** + + Constrains effort on reasoning for + [reasoning models](https://platform.openai.com/docs/guides/reasoning). + Currently supported values are `low`, `medium`, and `high`. Reducing + reasoning effort can result in faster responses and fewer tokens used + on reasoning in a response. + default: medium metadata: type: object additionalProperties: @@ -4787,9 +4957,9 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + their existing frequency in the text so far, decreasing the model's + likelihood to repeat the same line verbatim. default: 0 logit_bias: type: object @@ -4800,13 +4970,21 @@ components: description: |- Modify the likelihood of specified tokens appearing in the completion. - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + Accepts a JSON object that maps tokens (specified by their token ID in the + tokenizer) to an associated bias value from -100 to 100. Mathematically, + the bias is added to the logits generated by the model prior to sampling. + The exact effect will vary per model, but values between -1 and 1 should + decrease or increase likelihood of selection; values like -100 or 100 + should result in a ban or exclusive selection of the relevant token. x-oaiTypeLabel: map default: null logprobs: type: boolean nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + description: |- + Whether to return log probabilities of the output tokens or not. If true, + returns the log probabilities of each output token returned in the + `content` of `message`. default: false top_logprobs: type: integer @@ -4814,15 +4992,21 @@ components: nullable: true minimum: 0 maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + description: |- + An integer between 0 and 20 specifying the number of most likely tokens to + return at each token position, each with an associated log probability. + `logprobs` must be set to `true` if this parameter is used. max_tokens: type: integer format: int32 nullable: true description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + The maximum number of [tokens](/tokenizer) that can be generated in the + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + This value is now deprecated in favor of `max_completion_tokens`, and is + not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true max_completion_tokens: type: integer @@ -4842,6 +5026,17 @@ components: allOf: - $ref: '#/components/schemas/ChatCompletionModalities' nullable: true + prediction: + type: object + allOf: + - $ref: '#/components/schemas/PredictionContent' + nullable: true + description: |- + Configuration for a [Predicted Output](/docs/guides/predicted-outputs), + which can greatly improve response times when large parts of the model + response are known ahead of time. This is most common when you are + regenerating a file with only minor changes to most of the content. + x-oaiExpandable: true audio: type: object properties: @@ -4849,14 +5044,14 @@ components: type: string enum: - alloy + - ash + - ballad + - coral - echo - - fable - - onyx - - nova + - sage - shimmer - description: |- - Specifies the voice type. Supported voices are `alloy`, `echo`, - `fable`, `onyx`, `nova`, and `shimmer`. + - verse + description: The voice the model uses to respond. Supported voices are `ash`, `ballad`, `coral`, `sage`, and `verse` (also supported but not recommended are `alloy`, `echo`, and `shimmer`; these voices are less expressive). format: type: string enum: @@ -4883,21 +5078,31 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + whether they appear in the text so far, increasing the model's likelihood + to talk about new topics. default: 0 response_format: allOf: - $ref: '#/components/schemas/ChatResponseFormat' description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + An object specifying the format that the model must output. - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + **Important:** when using JSON mode, you **must** also instruct the model + to produce JSON yourself via a system or user message. Without this, the + model may generate an unending stream of whitespace until the generation + reaches the token limit, resulting in a long-running and seemingly "stuck" + request. Also note that the message content may be partially cut off if + `finish_reason="length"`, which indicates the generation exceeded + `max_tokens` or the conversation exceeded the max context length. x-oaiExpandable: true seed: type: integer @@ -4917,7 +5122,7 @@ components: nullable: true description: |- Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. + - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - When not set, the default behavior is 'auto'. @@ -4952,7 +5157,6 @@ components: maximum: 2 description: |- What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. default: 1 top_p: @@ -4962,7 +5166,10 @@ components: minimum: 0 maximum: 1 description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + An alternative to sampling with temperature, called nucleus sampling, + where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass + are considered. We generally recommend altering this or `temperature` but not both. default: 1 @@ -4978,7 +5185,7 @@ components: default: true user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). function_call: anyOf: - type: string @@ -4990,11 +5197,18 @@ components: Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - `none` is the default when no functions are present. `auto` is the default if functions are present. + `none` means the model will not call a function and instead generates a + message. + + `auto` means the model can pick between generating a message or calling a + function. + + Specifying a particular function via `{"name": "my_function"}` forces the + model to call that function. + + `none` is the default when no functions are present. `auto` is the default + if functions are present. deprecated: true x-oaiExpandable: true functions: @@ -5228,7 +5442,7 @@ components: - gpt-3.5-turbo-instruct - davinci-002 - babbage-002 - description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. x-oaiTypeLabel: string prompt: anyOf: @@ -5279,7 +5493,7 @@ components: description: |- Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + [See more information about frequency and presence penalties.](/docs/guides/text-generation) default: 0 logit_bias: type: object @@ -5336,7 +5550,7 @@ components: description: |- Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + [See more information about frequency and presence penalties.](/docs/guides/text-generation) default: 0 seed: type: integer @@ -5400,7 +5614,7 @@ components: default: 1 user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). CreateCompletionResponse: type: object required: @@ -5507,7 +5721,7 @@ components: items: type: integer format: int32 - description: Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. + description: Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. Some models may also impose a limit on total number of tokens summed across inputs. x-oaiExpandable: true model: anyOf: @@ -5517,7 +5731,7 @@ components: - text-embedding-ada-002 - text-embedding-3-small - text-embedding-3-large - description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. x-oaiTypeLabel: string encoding_format: type: string @@ -5533,7 +5747,7 @@ components: description: The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models. user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). CreateEmbeddingResponse: type: object required: @@ -5607,7 +5821,7 @@ components: - gpt-4o-mini description: |- The name of the model to fine-tune. You can select one of the - [supported models](/docs/guides/fine-tuning/which-models-can-be-fine-tuned). + [supported models](/docs/guides/fine-tuning#which-models-can-be-fine-tuned). x-oaiTypeLabel: string training_file: type: string @@ -5618,13 +5832,49 @@ components: Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`. - The contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) format. + The contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input), [completions](/docs/api-reference/fine-tuning/completions-input) format, or if the fine-tuning method uses the [preference](/docs/api-reference/fine-tuning/preference-input) format. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. hyperparameters: - allOf: - - $ref: '#/components/schemas/CreateFineTuningJobRequestHyperparameters' - description: The hyperparameters used for the fine-tuning job. + type: object + properties: + batch_size: + anyOf: + - type: string + enum: + - auto + - type: integer + format: int32 + description: |- + Number of examples in each batch. A larger batch size means that model parameters + are updated less frequently, but with lower variance. + default: auto + learning_rate_multiplier: + anyOf: + - type: string + enum: + - auto + - type: number + format: float + description: |- + Scaling factor for the learning rate. A smaller learning rate may be useful to avoid + overfitting. + default: auto + n_epochs: + anyOf: + - type: string + enum: + - auto + - type: integer + format: int32 + description: |- + The number of epochs to train the model for. An epoch refers to one full cycle + through the training dataset. + default: auto + description: |- + The hyperparameters used for the fine-tuning job. + This value is now deprecated in favor of `method`, and should be passed in under the `method` parameter. + deprecated: true suffix: type: string nullable: true @@ -5664,41 +5914,8 @@ components: description: |- The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. If a seed is not specified, one will be generated for you. - CreateFineTuningJobRequestHyperparameters: - type: object - properties: - n_epochs: - anyOf: - - $ref: '#/components/schemas/CreateFineTuningJobRequestHyperparametersNEpochsChoiceEnum' - - type: integer - format: int32 - minimum: 1 - maximum: 50 - description: |- - The number of epochs to train the model for. An epoch refers to one full cycle - through the training dataset. - default: auto - batch_size: - anyOf: - - $ref: '#/components/schemas/CreateFineTuningJobRequestHyperparametersBatchSizeChoiceEnum' - - type: integer - format: int32 - minimum: 1 - maximum: 256 - description: |- - Number of examples in each batch. A larger batch size means that model parameters - are updated less frequently, but with lower variance. - default: auto - learning_rate_multiplier: - anyOf: - - $ref: '#/components/schemas/CreateFineTuningJobRequestHyperparametersLearningRateMultiplierChoiceEnum' - - type: number - format: float - minimum: 0 - description: |- - Scaling factor for the learning rate. A smaller learning rate may be useful to avoid - overfitting. - default: auto + method: + $ref: '#/components/schemas/FineTuneMethod' CreateFineTuningJobRequestHyperparametersBatchSizeChoiceEnum: type: string enum: @@ -5807,7 +6024,7 @@ components: default: url user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). CreateImageRequest: type: object required: @@ -5871,7 +6088,7 @@ components: default: vivid user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). CreateImageVariationRequestMultiPart: type: object required: @@ -5917,7 +6134,7 @@ components: default: 1024x1024 user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). CreateMessageRequest: type: object required: @@ -6032,7 +6249,7 @@ components: description: |- The content moderation model you would like to use. Learn more in [the moderation guide](/docs/guides/moderation), and learn about - available models [here](/docs/models/moderation). + available models [here](/docs/models#moderation). x-oaiTypeLabel: string default: omni-moderation-latest CreateModerationResponse: @@ -6339,6 +6556,7 @@ components: - type: string enum: - gpt-4o + - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - gpt-4o-mini @@ -6466,7 +6684,7 @@ components: enum: - tts-1 - tts-1-hd - description: 'One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd`' + description: 'One of the available [TTS models](/docs/models#tts): `tts-1` or `tts-1-hd`' x-oaiTypeLabel: string input: type: string @@ -6476,12 +6694,15 @@ components: type: string enum: - alloy + - ash + - coral - echo - fable - onyx - nova + - sage - shimmer - description: The voice to use when generating the audio. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech/voice-options). + description: The voice to use when generating the audio. Supported voices are `alloy`, `ash`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech#voice-options). response_format: type: string enum: @@ -6518,6 +6739,7 @@ components: - type: string enum: - gpt-4o + - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - gpt-4o-mini @@ -6730,7 +6952,7 @@ components: description: The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. prompt: type: string - description: An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. + description: An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should match the audio language. response_format: allOf: - $ref: '#/components/schemas/TranscriptionAudioResponseFormat' @@ -6816,7 +7038,7 @@ components: x-oaiTypeLabel: string prompt: type: string - description: An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. + description: An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should be in English. response_format: allOf: - $ref: '#/components/schemas/TranslationAudioResponseFormat' @@ -7155,59 +7377,233 @@ components: description: |- The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. FineTuneChatCompletionRequestAssistantMessage: type: object allOf: - $ref: '#/components/schemas/ChatCompletionRequestAssistantMessage' - FineTuningIntegration: + FineTuneChatRequestInput: type: object - required: - - type properties: - type: + messages: + type: array + items: + anyOf: + - $ref: '#/components/schemas/ChatCompletionRequestSystemMessage' + - $ref: '#/components/schemas/ChatCompletionRequestUserMessage' + - $ref: '#/components/schemas/FineTuneChatCompletionRequestAssistantMessage' + - $ref: '#/components/schemas/ChatCompletionRequestToolMessage' + - $ref: '#/components/schemas/ChatCompletionRequestFunctionMessage' + minItems: 1 + x-oaiExpandable: true + tools: + type: array + items: + $ref: '#/components/schemas/ChatCompletionTool' + description: A list of tools the model may generate JSON inputs for. + parallel_tool_calls: + type: boolean + default: true + functions: + type: array + items: + $ref: '#/components/schemas/ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: A list of functions the model may generate JSON inputs for. + deprecated: true + description: The per-line training example of a fine-tuning input file for chat models using the supervised method. + FineTuneCompletionRequestInput: + type: object + properties: + prompt: type: string - discriminator: - propertyName: type - mapping: - wandb: '#/components/schemas/FineTuningIntegrationWandb' - FineTuningIntegrationWandb: + description: The input prompt for this training example. + completion: + type: string + description: The desired completion for this training example. + description: The per-line training example of a fine-tuning input file for completions models + FineTuneDPOMethod: + type: object + properties: + hyperparameters: + type: object + properties: + beta: + anyOf: + - type: string + enum: + - auto + - type: number + format: float + description: The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model. + default: auto + batch_size: + anyOf: + - type: string + enum: + - auto + - type: integer + format: int32 + description: Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance. + default: auto + learning_rate_multiplier: + anyOf: + - type: string + enum: + - auto + - type: number + format: float + description: Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting. + default: auto + n_epochs: + anyOf: + - type: string + enum: + - auto + - type: integer + format: int32 + description: The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. + default: auto + description: The hyperparameters used for the fine-tuning job. + description: Configuration for the DPO fine-tuning method. + FineTuneMethod: type: object - required: - - type - - wandb properties: type: type: string enum: - - wandb - description: The type of the integration being enabled for the fine-tuning job - wandb: + - supervised + - dpo + description: The type of method. Is either `supervised` or `dpo`. + supervised: + $ref: '#/components/schemas/FineTuneSupervisedMethod' + dpo: + $ref: '#/components/schemas/FineTuneDPOMethod' + description: The method used for fine-tuning. + FineTunePreferenceRequestInput: + type: object + properties: + input: type: object properties: - project: - type: string - description: The name of the project that the new run will be created under. - name: - type: string - nullable: true - description: A display name to set for the run. If not set, we will use the Job ID as the name. - entity: - type: string - nullable: true - description: |- - The entity to use for the run. This allows you to set the team or username of the WandB user that you would - like associated with the run. If not set, the default entity for the registered WandB API key is used. - tags: + messages: type: array items: - type: string - description: |- - A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some - default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". - required: - - project - description: |- + anyOf: + - $ref: '#/components/schemas/ChatCompletionRequestSystemMessage' + - $ref: '#/components/schemas/ChatCompletionRequestUserMessage' + - $ref: '#/components/schemas/FineTuneChatCompletionRequestAssistantMessage' + - $ref: '#/components/schemas/ChatCompletionRequestToolMessage' + - $ref: '#/components/schemas/ChatCompletionRequestFunctionMessage' + minItems: 1 + x-oaiExpandable: true + tools: + type: array + items: + $ref: '#/components/schemas/ChatCompletionTool' + description: A list of tools the model may generate JSON inputs for. + parallel_tool_calls: + type: boolean + default: true + preferred_completion: + type: array + items: + $ref: '#/components/schemas/ChatCompletionRequestAssistantMessage' + maxItems: 1 + description: The preferred completion message for the output. + x-oaiExpandable: true + non_preferred_completion: + type: array + items: + $ref: '#/components/schemas/ChatCompletionRequestAssistantMessage' + maxItems: 1 + description: The non-preferred completion message for the output. + x-oaiExpandable: true + description: The per-line training example of a fine-tuning input file for chat models using the dpo method. + FineTuneSupervisedMethod: + type: object + properties: + hyperparameters: + type: object + properties: + batch_size: + anyOf: + - type: string + enum: + - auto + - type: integer + format: int32 + description: Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance. + default: auto + learning_rate_multiplier: + anyOf: + - type: string + enum: + - auto + - type: number + format: float + description: Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting. + default: auto + n_epochs: + anyOf: + - type: string + enum: + - auto + - type: integer + format: int32 + description: The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. + default: auto + description: The hyperparameters used for the fine-tuning job. + description: Configuration for the supervised fine-tuning method. + FineTuningIntegration: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + wandb: '#/components/schemas/FineTuningIntegrationWandb' + FineTuningIntegrationWandb: + type: object + required: + - type + - wandb + properties: + type: + type: string + enum: + - wandb + description: The type of the integration being enabled for the fine-tuning job + wandb: + type: object + properties: + project: + type: string + description: The name of the project that the new run will be created under. + name: + type: string + nullable: true + description: A display name to set for the run. If not set, we will use the Job ID as the name. + entity: + type: string + nullable: true + description: |- + The entity to use for the run. This allows you to set the team or username of the WandB user that you would + like associated with the run. If not set, the default entity for the registered WandB API key is used. + tags: + type: array + items: + type: string + description: |- + A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some + default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". + required: + - project + description: |- The settings for your integration with Weights and Biases. This payload specifies the project that metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags to your run, and set a default entity (team, username, etc) to be associated with your run. @@ -7272,9 +7668,42 @@ components: nullable: true description: The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running. hyperparameters: - allOf: - - $ref: '#/components/schemas/FineTuningJobHyperparameters' - description: The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. + type: object + properties: + batch_size: + anyOf: + - type: string + enum: + - auto + - type: integer + format: int32 + description: |- + Number of examples in each batch. A larger batch size means that model parameters + are updated less frequently, but with lower variance. + default: auto + learning_rate_multiplier: + anyOf: + - type: string + enum: + - auto + - type: number + format: float + description: |- + Scaling factor for the learning rate. A smaller learning rate may be useful to avoid + overfitting. + default: auto + n_epochs: + anyOf: + - type: string + enum: + - auto + - type: integer + format: int32 + description: |- + The number of epochs to train the model for. An epoch refers to one full cycle + through the training dataset. + default: auto + description: The hyperparameters used for the fine-tuning job. This value will only be returned when running `supervised` jobs. model: type: string description: The base model that is being fine-tuned. @@ -7328,6 +7757,8 @@ components: format: unixtime nullable: true description: The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running. + method: + $ref: '#/components/schemas/FineTuneMethod' description: The `fine_tuning.job` object represents a fine-tuning job that has been created through the API. FineTuningJobCheckpoint: type: object @@ -7391,64 +7822,43 @@ components: FineTuningJobEvent: type: object required: + - object - id - created_at - level - message - - object properties: + object: + type: string + enum: + - fine_tuning.job.event + description: The object type, which is always "fine_tuning.job.event". id: type: string + description: The object identifier. created_at: type: integer format: unixtime + description: The Unix timestamp (in seconds) for when the fine-tuning job was created. level: type: string enum: - info - warn - error + description: The log level of the event. message: type: string - object: + description: The message of the event. + type: type: string enum: - - fine_tuning.job.event + - message + - metrics + description: The type of event. + data: + description: The data associated with the event. description: Fine-tuning job event object - FineTuningJobHyperparameters: - type: object - required: - - n_epochs - - batch_size - - learning_rate_multiplier - properties: - n_epochs: - anyOf: - - $ref: '#/components/schemas/FineTuningJobHyperparametersNEpochsChoiceEnum' - - type: integer - format: int32 - description: |- - The number of epochs to train the model for. An epoch refers to one full cycle - through the training dataset. - default: auto - batch_size: - anyOf: - - $ref: '#/components/schemas/FineTuningJobHyperparametersBatchSizeChoiceEnum' - - type: integer - format: int32 - description: |- - Number of examples in each batch. A larger batch size means that model parameters - are updated less frequently, but with lower variance. - default: auto - learning_rate_multiplier: - anyOf: - - $ref: '#/components/schemas/FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum' - - type: number - format: float - description: |- - Scaling factor for the learning rate. A smaller learning rate may be useful to avoid - overfitting. - default: auto FineTuningJobHyperparametersBatchSizeChoiceEnum: type: string enum: @@ -7467,47 +7877,6 @@ components: $ref: '#/components/schemas/FineTuningIntegration' maxItems: 5 x-oaiExpandable: true - FinetuneChatRequestInput: - type: object - properties: - messages: - type: array - items: - anyOf: - - $ref: '#/components/schemas/ChatCompletionRequestSystemMessage' - - $ref: '#/components/schemas/ChatCompletionRequestUserMessage' - - $ref: '#/components/schemas/FineTuneChatCompletionRequestAssistantMessage' - - $ref: '#/components/schemas/ChatCompletionRequestToolMessage' - - $ref: '#/components/schemas/ChatCompletionRequestFunctionMessage' - minItems: 1 - x-oaiExpandable: true - tools: - type: array - items: - $ref: '#/components/schemas/ChatCompletionTool' - description: A list of tools the model may generate JSON inputs for. - parallel_tool_calls: - type: boolean - default: true - functions: - type: array - items: - $ref: '#/components/schemas/ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: A list of functions the model may generate JSON inputs for. - deprecated: true - description: The per-line training example of a fine-tuning input file for chat models - FinetuneCompletionRequestInput: - type: object - properties: - prompt: - type: string - description: The input prompt for this training example. - completion: - type: string - description: The desired completion for this training example. - description: The per-line training example of a fine-tuning input file for completions models FunctionObject: type: object required: @@ -7614,6 +7983,21 @@ components: type: integer format: unixtime description: The Unix timestamp (in seconds) of when the invite was accepted. + projects: + type: array + items: + type: object + properties: + id: + type: string + description: Project's public ID + role: + type: string + enum: + - member + - owner + description: Project membership role + description: The projects that were granted membership upon acceptance of the invite. description: Represents an individual `invite` to the organization. InviteDeleteResponse: type: object @@ -7670,6 +8054,24 @@ components: - reader - owner description: '`owner` or `reader`' + projects: + type: array + items: + type: object + properties: + id: + type: string + description: Project's public ID + role: + type: string + enum: + - member + - owner + description: Project membership role + required: + - id + - role + description: An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. ListAssistantsResponse: type: object required: @@ -7741,17 +8143,24 @@ components: ListFilesResponse: type: object required: - - data - object + - data + - first_id + - last_id + - has_more properties: + object: + type: string data: type: array items: $ref: '#/components/schemas/OpenAIFile' - object: + first_id: type: string - enum: - - list + last_id: + type: string + has_more: + type: boolean ListFineTuningJobCheckpointsResponse: type: object required: @@ -8588,7 +8997,7 @@ components: properties: model: type: string - description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. name: type: string nullable: true @@ -8786,6 +9195,33 @@ components: allOf: - $ref: '#/components/schemas/FileChunkingStrategyResponseParam' description: This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API. + PredictionContent: + type: object + required: + - type + - content + properties: + type: + type: string + enum: + - content + description: |- + The type of the predicted content you want to provide. This type is + currently always `content`. + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' + description: |- + The content that should be matched when generating a model response. + If generated tokens would match this content, the entire model response + can be returned much more quickly. + x-oaiExpandable: true + description: |- + Static predicted output content, such as the content of a text file that is + being regenerated. Project: type: object required: @@ -8933,53 +9369,148 @@ components: type: string has_more: type: boolean - ProjectServiceAccount: + ProjectRateLimit: type: object required: - object - id - - name - - role - - created_at + - model + - max_requests_per_1_minute + - max_tokens_per_1_minute properties: object: type: string enum: - - organization.project.service_account - description: The object type, which is always `organization.project.service_account` + - project.rate_limit + description: The object type, which is always `project.rate_limit` id: type: string - description: The identifier, which can be referenced in API endpoints - name: - type: string - description: The name of the service account - role: + description: The identifier, which can be referenced in API endpoints. + model: type: string - enum: - - owner - - member - description: '`owner` or `member`' - created_at: + description: The model this rate limit applies to. + max_requests_per_1_minute: type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the service account was created - description: Represents an individual service account in a project. - ProjectServiceAccountApiKey: + format: int32 + description: The maximum requests per minute. + max_tokens_per_1_minute: + type: integer + format: int32 + description: The maximum tokens per minute. + max_images_per_1_minute: + type: integer + format: int32 + description: The maximum images per minute. Only present for relevant models. + max_audio_megabytes_per_1_minute: + type: integer + format: int32 + description: The maximum audio megabytes per minute. Only present for relevant models. + max_requests_per_1_day: + type: integer + format: int32 + description: The maximum requests per day. Only present for relevant models. + batch_1_day_max_input_tokens: + type: integer + format: int32 + description: The maximum batch input tokens per day. Only present for relevant models. + description: Represents a project rate limit config. + ProjectRateLimitListResponse: type: object required: - object - - value - - name - - created_at - - id + - data + - first_id + - last_id + - has_more properties: object: type: string enum: - - organization.project.service_account.api_key - description: The object type, which is always `organization.project.service_account.api_key` - value: - type: string + - list + data: + type: array + items: + $ref: '#/components/schemas/ProjectRateLimit' + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + ProjectRateLimitUpdateRequest: + type: object + properties: + max_requests_per_1_minute: + type: integer + format: int32 + description: The maximum requests per minute. + max_tokens_per_1_minute: + type: integer + format: int32 + description: The maximum tokens per minute. + max_images_per_1_minute: + type: integer + format: int32 + description: The maximum images per minute. Only relevant for certain models. + max_audio_megabytes_per_1_minute: + type: integer + format: int32 + description: The maximum audio megabytes per minute. Only relevant for certain models. + max_requests_per_1_day: + type: integer + format: int32 + description: The maximum requests per day. Only relevant for certain models. + batch_1_day_max_input_tokens: + type: integer + format: int32 + description: The maximum batch input tokens per day. Only relevant for certain models. + ProjectServiceAccount: + type: object + required: + - object + - id + - name + - role + - created_at + properties: + object: + type: string + enum: + - organization.project.service_account + description: The object type, which is always `organization.project.service_account` + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + type: string + description: The name of the service account + role: + type: string + enum: + - owner + - member + description: '`owner` or `member`' + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the service account was created + description: Represents an individual service account in a project. + ProjectServiceAccountApiKey: + type: object + required: + - object + - value + - name + - created_at + - id + properties: + object: + type: string + enum: + - organization.project.service_account.api_key + description: The object type, which is always `organization.project.service_account.api_key` + value: + type: string name: type: string created_at: @@ -9221,14 +9752,23 @@ components: description: The event type, must be `conversation.item.create`. previous_item_id: type: string - description: The ID of the preceding item after which the new item will be inserted. If not set, the new item will be appended to the end of the conversation. If set, it allows an item to be inserted mid-conversation. If the ID cannot be found, an error will be returned and the item will not be added. + description: |- + The ID of the preceding item after which the new item will be inserted. + If not set, the new item will be appended to the end of the conversation. + If set, it allows an item to be inserted mid-conversation. If the ID + cannot be found, an error will be returned and the item will not be added. item: $ref: '#/components/schemas/RealtimeConversationRequestItem' allOf: - $ref: '#/components/schemas/RealtimeClientEvent' description: |- - Add a new Item to the Conversation's context, including messages, function calls, and function call responses. This event can be used both to populate a "history" of the conversation and to add new items mid-stream, but has the current limitation that it cannot populate assistant audio messages. - If successful, the server will respond with a `conversation.item.created` event, otherwise an `error` event will be sent. + Add a new Item to the Conversation's context, including messages, function + calls, and function call responses. This event can be used both to populate a + "history" of the conversation and to add new items mid-stream, but has the + current limitation that it cannot populate assistant audio messages. + + If successful, the server will respond with a `conversation.item.created` + event, otherwise an `error` event will be sent. RealtimeClientEventConversationItemDelete: type: object required: @@ -9239,13 +9779,17 @@ components: type: string enum: - conversation.item.delete - description: The event type, must be "conversation.item.delete". + description: The event type, must be `conversation.item.delete`. item_id: type: string description: The ID of the item to delete. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event when you want to remove any item from the conversation history. The server will respond with a `conversation.item.deleted` event, unless the item does not exist in the conversation history, in which case the server will respond with an error. + description: |- + Send this event when you want to remove any item from the conversation + history. The server will respond with a `conversation.item.deleted` event, + unless the item does not exist in the conversation history, in which case the + server will respond with an error. RealtimeClientEventConversationItemTruncate: type: object required: @@ -9258,10 +9802,12 @@ components: type: string enum: - conversation.item.truncate - description: The event type, must be "conversation.item.truncate". + description: The event type, must be `conversation.item.truncate`. item_id: type: string - description: The ID of the assistant message item to truncate. Only assistant message items can be truncated. + description: |- + The ID of the assistant message item to truncate. Only assistant message + items can be truncated. content_index: type: integer format: int32 @@ -9269,13 +9815,24 @@ components: audio_end_ms: type: integer format: int32 - description: Inclusive duration up to which audio is truncated, in milliseconds. If the audio_end_ms is greater than the actual audio duration, the server will respond with an error. + description: |- + Inclusive duration up to which audio is truncated, in milliseconds. If + the audio_end_ms is greater than the actual audio duration, the server + will respond with an error. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' description: |- - Send this event to truncate a previous assistant message’s audio. The server will produce audio faster than realtime, so this event is useful when the user interrupts to truncate audio that has already been sent to the client but not yet played. This will synchronize the server's understanding of the audio with the client's playback. - Truncating audio will delete the server-side text transcript to ensure there is not text in the context that hasn't been heard by the user. - If successful, the server will respond with a `conversation.item.truncated` event. + Send this event to truncate a previous assistant message’s audio. The server + will produce audio faster than realtime, so this event is useful when the user + interrupts to truncate audio that has already been sent to the client but not + yet played. This will synchronize the server's understanding of the audio with + the client's playback. + + Truncating audio will delete the server-side text transcript to ensure there + is not text in the context that hasn't been heard by the user. + + If successful, the server will respond with a `conversation.item.truncated` + event. RealtimeClientEventInputAudioBufferAppend: type: object required: @@ -9286,16 +9843,26 @@ components: type: string enum: - input_audio_buffer.append - description: The event type, must be "input_audio_buffer.append". + description: The event type, must be `input_audio_buffer.append`. audio: type: string format: base64 - description: Base64-encoded audio bytes. This must be in the format specified by the `input_audio_format` field in the session configuration. + description: |- + Base64-encoded audio bytes. This must be in the format specified by the + `input_audio_format` field in the session configuration. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' description: |- - Send this event to append audio bytes to the input audio buffer. The audio buffer is temporary storage you can write to and later commit. In Server VAD mode, the audio buffer is used to detect speech and the server will decide when to commit. When Server VAD is disabled, you must commit the audio buffer manually. - The client may choose how much audio to place in each event up to a maximum of 15 MiB, for example streaming smaller chunks from the client may allow the VAD to be more responsive. Unlike made other client events, the server will not send a confirmation response to this event. + Send this event to append audio bytes to the input audio buffer. The audio + buffer is temporary storage you can write to and later commit. In Server VAD + mode, the audio buffer is used to detect speech and the server will decide + when to commit. When Server VAD is disabled, you must commit the audio buffer + manually. + + The client may choose how much audio to place in each event up to a maximum + of 15 MiB, for example streaming smaller chunks from the client may allow the + VAD to be more responsive. Unlike made other client events, the server will + not send a confirmation response to this event. RealtimeClientEventInputAudioBufferClear: type: object required: @@ -9305,10 +9872,12 @@ components: type: string enum: - input_audio_buffer.clear - description: The event type, must be "input_audio_buffer.clear". + description: The event type, must be `input_audio_buffer.clear`. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event to clear the audio bytes in the buffer. The server will respond with an `input_audio_buffer.cleared` event. + description: |- + Send this event to clear the audio bytes in the buffer. The server will + respond with an `input_audio_buffer.cleared` event. RealtimeClientEventInputAudioBufferCommit: type: object required: @@ -9318,12 +9887,20 @@ components: type: string enum: - input_audio_buffer.commit - description: The event type, must be "input_audio_buffer.commit". + description: The event type, must be `input_audio_buffer.commit`. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' description: |- - Send this event to commit the user input audio buffer, which will create a new user message item in the conversation. This event will produce an error if the input audio buffer is empty. When in Server VAD mode, the client does not need to send this event, the server will commit the audio buffer automatically. - Committing the input audio buffer will trigger input audio transcription (if enabled in session configuration), but it will not create a response from the model. The server will respond with an `input_audio_buffer.committed` event. + Send this event to commit the user input audio buffer, which will create a + new user message item in the conversation. This event will produce an error + if the input audio buffer is empty. When in Server VAD mode, the client does + not need to send this event, the server will commit the audio buffer + automatically. + + Committing the input audio buffer will trigger input audio transcription + (if enabled in session configuration), but it will not create a response + from the model. The server will respond with an `input_audio_buffer.committed` + event. RealtimeClientEventResponseCancel: type: object required: @@ -9334,14 +9911,21 @@ components: enum: - response.cancel description: The event type, must be `response.cancel`. + response_id: + type: string + description: |- + A specific response ID to cancel - if not provided, will cancel an + in-progress response in the default conversation. allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event to cancel an in-progress response. The server will respond with a `response.cancelled` event or an error if there is no response to cancel. + description: |- + Send this event to cancel an in-progress response. The server will respond + with a `response.cancelled` event or an error if there is no response to + cancel. RealtimeClientEventResponseCreate: type: object required: - type - - response properties: type: type: string @@ -9349,14 +9933,25 @@ components: - response.create description: The event type, must be `response.create`. response: - $ref: '#/components/schemas/RealtimeResponseOptions' + $ref: '#/components/schemas/RealtimeResponseCreateParams' allOf: - $ref: '#/components/schemas/RealtimeClientEvent' description: |- - This event instructs the server to create a Response, which means triggering model inference. When in Server VAD mode, the server will create Responses automatically. - A Response will include at least one Item, and may have two, in which case the second will be a function call. These Items will be appended to the conversation history. - The server will respond with a `response.created` event, events for Items and content created, and finally a `response.done` event to indicate the Response is complete. - The `response.create` event includes inference configuration like `instructions`, and `temperature`. These fields will override the Session's configuration for this Response only. + This event instructs the server to create a Response, which means triggering + model inference. When in Server VAD mode, the server will create Responses + automatically. + + A Response will include at least one Item, and may have two, in which case + the second will be a function call. These Items will be appended to the + conversation history. + + The server will respond with a `response.created` event, events for Items + and content created, and finally a `response.done` event to indicate the + Response is complete. + + The `response.create` event includes inference configuration like + `instructions`, and `temperature`. These fields will override the Session's + configuration for this Response only. RealtimeClientEventSessionUpdate: type: object required: @@ -9367,12 +9962,18 @@ components: type: string enum: - session.update - description: The event type, must be "session.update". + description: The event type, must be `session.update`. session: $ref: '#/components/schemas/RealtimeRequestSession' allOf: - $ref: '#/components/schemas/RealtimeClientEvent' - description: Send this event to update the session’s default configuration. The client may send this event at any time to update the session configuration, and any field may be updated at any time, except for "voice". The server will respond with a `session.updated` event that shows the full effective configuration. Only fields that are present are updated, thus the correct way to clear a field like "instructions" is to pass an empty string. + description: |- + Send this event to update the session’s default configuration. The client may + send this event at any time to update the session configuration, and any + field may be updated at any time, except for "voice". The server will respond + with a `session.updated` event that shows the full effective configuration. + Only fields that are present are updated, thus the correct way to clear a + field like "instructions" is to pass an empty string. RealtimeClientEventType: anyOf: - type: string @@ -9413,6 +10014,7 @@ components: RealtimeConversationItemBase: type: object description: The item to add to the conversation. + x-oaiExpandable: true RealtimeConversationRequestItem: type: object required: @@ -9492,6 +10094,13 @@ components: - system - user - assistant + RealtimeModality: + anyOf: + - type: string + - type: string + enum: + - text + - audio RealtimeRequestAssistantMessageItem: type: object required: @@ -9600,12 +10209,19 @@ components: modalities: type: array items: - type: string - enum: - - text - - audio + $ref: '#/components/schemas/RealtimeModality' instructions: type: string + model: + anyOf: + - type: string + - type: string + enum: + - gpt-4o-realtime-preview + - gpt-4o-realtime-preview-2024-10-01 + - gpt-4o-realtime-preview-2024-12-17 + - gpt-4o-mini-realtime-preview + - gpt-4o-mini-realtime-preview-2024-12-17 voice: $ref: '#/components/schemas/RealtimeVoice' input_audio_format: @@ -9688,79 +10304,132 @@ components: - $ref: '#/components/schemas/RealtimeRequestMessageItem' RealtimeResponse: type: object - required: - - object - - id - - status - - status_details - - output - - usage properties: + id: + type: string + description: The unique ID of the response. object: type: string enum: - realtime.response - id: - type: string + description: The object type, must be `realtime.response`. status: - allOf: - - $ref: '#/components/schemas/RealtimeResponseStatus' - default: in_progress + type: string + enum: + - completed + - cancelled + - failed + - incomplete + description: |- + The final status of the response (`completed`, `cancelled`, `failed`, or + `incomplete`). status_details: type: object - allOf: - - $ref: '#/components/schemas/RealtimeResponseStatusDetails' - nullable: true + properties: + type: + type: string + enum: + - completed + - cancelled + - failed + - incomplete + description: |- + The type of error that caused the response to fail, corresponding + with the `status` field (`completed`, `cancelled`, `incomplete`, + `failed`). + reason: + type: string + enum: + - turn_detected + - client_cancelled + - max_output_tokens + - content_filter + description: |- + The reason the Response did not complete. For a `cancelled` Response, + one of `turn_detected` (the server VAD detected a new start of speech) + or `client_cancelled` (the client sent a cancel event). For an + `incomplete` Response, one of `max_output_tokens` or `content_filter` + (the server-side safety filter activated and cut off the response). + error: + type: object + properties: + type: + type: string + description: The type of error. + code: + type: string + description: Error code, if any. + description: |- + A description of the error that caused the response to fail, + populated when the `status` is `failed`. + description: Additional details about the status. output: type: array items: $ref: '#/components/schemas/RealtimeConversationResponseItem' + description: The list of output items generated by the response. + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: Developer-provided string key-value pairs associated with this response. + x-oaiTypeLabel: map usage: type: object properties: total_tokens: type: integer format: int32 + description: |- + The total number of tokens in the Response including input and output + text and audio tokens. input_tokens: type: integer format: int32 + description: |- + The number of input tokens used in the Response, including text and + audio tokens. output_tokens: type: integer format: int32 + description: |- + The number of output tokens sent in the Response, including text and + audio tokens. input_token_details: type: object properties: cached_tokens: type: integer format: int32 + description: The number of cached tokens used in the Response. text_tokens: type: integer format: int32 + description: The number of text tokens used in the Response. audio_tokens: type: integer format: int32 - required: - - cached_tokens - - text_tokens - - audio_tokens + description: The number of audio tokens used in the Response. + description: Details about the input tokens used in the Response. output_token_details: type: object properties: text_tokens: type: integer format: int32 + description: The number of text tokens used in the Response. audio_tokens: type: integer format: int32 - required: - - text_tokens - - audio_tokens - required: - - total_tokens - - input_tokens - - output_tokens - - input_token_details - - output_token_details + description: The number of audio tokens used in the Response. + description: Details about the output tokens used in the Response. + description: |- + Usage statistics for the Response, this will correspond to billing. A + Realtime API session will maintain a conversation context and append new + Items to the Conversation, thus output from previous turns (text and + audio tokens) will become the input for later turns. + description: The response resource. RealtimeResponseAudioContentPart: type: object required: @@ -9776,9 +10445,102 @@ components: nullable: true allOf: - $ref: '#/components/schemas/RealtimeContentPart' - RealtimeResponseBase: + RealtimeResponseCreateParams: type: object - description: The response resource. + properties: + modalities: + type: array + items: + $ref: '#/components/schemas/RealtimeModality' + description: |- + The set of modalities the model can respond with. To disable audio, + set this to ["text"]. + instructions: + type: string + description: |- + The default system instructions (i.e. system message) prepended to model + calls. This field allows the client to guide the model on desired + responses. The model can be instructed on response content and format, + (e.g. "be extremely succinct", "act friendly", "here are examples of good + responses") and on audio behavior (e.g. "talk quickly", "inject emotion + into your voice", "laugh frequently"). The instructions are not guaranteed + to be followed by the model, but they provide guidance to the model on the + desired behavior. + + Note that the server sets default instructions which will be used if this + field is not set and are visible in the `session.created` event at the + start of the session. + voice: + allOf: + - $ref: '#/components/schemas/RealtimeVoice' + description: |- + The voice the model uses to respond. Voice cannot be changed during the + session once the model has responded with audio at least once. Current + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + `shimmer` and `verse`. + output_audio_format: + allOf: + - $ref: '#/components/schemas/RealtimeAudioFormat' + description: The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + tools: + type: array + items: + $ref: '#/components/schemas/RealtimeTool' + description: Tools (functions) available to the model. + tool_choice: + type: string + description: |- + How the model chooses tools. Options are `auto`, `none`, `required`, or + specify a function, like `{"type": "function", "function": {"name": "my_function"}}`. + temperature: + type: number + format: float + description: Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. + max_response_output_tokens: + anyOf: + - type: integer + format: int32 + - type: string + enum: + - inf + description: |- + Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. + conversation: + anyOf: + - type: string + - type: string + enum: + - auto + - none + description: |- + Controls which conversation the response is added to. Currently supports + `auto` and `none`, with `auto` as the default value. The `auto` value + means that the contents of the response will be added to the default + conversation. Set this to `none` to create an out-of-band response which + will not add items to default conversation. + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format. Keys can be a maximum of 64 characters long and values can be a + maximum of 512 characters long. + x-oaiTypeLabel: map + input: + type: array + items: + $ref: '#/components/schemas/RealtimeConversationRequestItem' + description: |- + Input items to include in the prompt for the model. Creates a new context + for this response, without including the default conversation. Can include + references to items from the default conversation. + description: Create a new Realtime response with these parameters RealtimeResponseFunctionCallItem: type: object required: @@ -9842,49 +10604,6 @@ components: $ref: '#/components/schemas/RealtimeItemStatus' allOf: - $ref: '#/components/schemas/RealtimeConversationResponseItem' - RealtimeResponseOptions: - type: object - properties: - modalities: - type: array - items: - type: string - enum: - - text - - audio - description: The modalities for the response. - instructions: - type: string - description: Instructions for the model. - voice: - allOf: - - $ref: '#/components/schemas/RealtimeVoice' - description: The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. - output_audio_format: - allOf: - - $ref: '#/components/schemas/RealtimeAudioFormat' - description: The format of output audio. - tools: - type: array - items: - $ref: '#/components/schemas/RealtimeTool' - description: Tools (functions) available to the model. - tool_choice: - allOf: - - $ref: '#/components/schemas/RealtimeToolChoice' - description: How the model chooses tools. - temperature: - type: number - format: float - description: Sampling temperature. - max_output_tokens: - anyOf: - - type: integer - format: int32 - - type: string - enum: - - inf - description: Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf". RealtimeResponseSession: type: object required: @@ -9914,10 +10633,7 @@ components: modalities: type: array items: - type: string - enum: - - text - - audio + $ref: '#/components/schemas/RealtimeModality' instructions: type: string voice: @@ -9951,25 +10667,6 @@ components: enum: - inf nullable: true - RealtimeResponseStatus: - anyOf: - - type: string - - type: string - enum: - - in_progress - - completed - - cancelled - - incomplete - - failed - RealtimeResponseStatusDetails: - type: object - required: - - type - properties: - type: - $ref: '#/components/schemas/RealtimeResponseStatus' - discriminator: - propertyName: type RealtimeResponseTextContentPart: type: object required: @@ -10035,7 +10732,7 @@ components: type: string enum: - conversation.created - description: The event type, must be "conversation.created". + description: The event type, must be `conversation.created`. conversation: type: object properties: @@ -10044,7 +10741,7 @@ components: description: The unique ID of the conversation. object: type: string - description: The object type, must be "realtime.conversation". + description: The object type, must be `realtime.conversation`. description: The conversation resource. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' @@ -10063,16 +10760,24 @@ components: description: The event type, must be `conversation.item.created`. previous_item_id: type: string - description: The ID of the preceding item in the Conversation context, allows the client to understand the order of the conversation. + description: |- + The ID of the preceding item in the Conversation context, allows the + client to understand the order of the conversation. item: $ref: '#/components/schemas/RealtimeConversationResponseItem' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' description: |- - Returned when a conversation item is created. There are several scenarios that produce this event: - - The server is generating a Response, which if successful will produce either one or two Items, which will be of type `message` (role `assistant`) or type `function_call`. - - The input audio buffer has been committed, either by the client or the server (in `server_vad` mode). The server will take the content of the input audio buffer and add it to a new user message Item. - - The client has sent a `conversation.item.create` event to add a new Item to the Conversation. + Returned when a conversation item is created. There are several scenarios that + produce this event: + - The server is generating a Response, which if successful will produce + either one or two Items, which will be of type `message` + (role `assistant`) or type `function_call`. + - The input audio buffer has been committed, either by the client or the + server (in `server_vad` mode). The server will take the content of the + input audio buffer and add it to a new user message Item. + - The client has sent a `conversation.item.create` event to add a new Item + to the Conversation. RealtimeServerEventConversationItemDeleted: type: object required: @@ -10089,7 +10794,10 @@ components: description: The ID of the item that was deleted. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when an item in the conversation is deleted by the client with a `conversation.item.delete` event. This event is used to synchronize the server's understanding of the conversation history with the client's view. + description: |- + Returned when an item in the conversation is deleted by the client with a + `conversation.item.delete` event. This event is used to synchronize the + server's understanding of the conversation history with the client's view. RealtimeServerEventConversationItemInputAudioTranscriptionCompleted: type: object required: @@ -10102,7 +10810,9 @@ components: type: string enum: - conversation.item.input_audio_transcription.completed - description: The event type, must be `conversation.item.input_audio_transcription.completed`. + description: |- + The event type, must be + `conversation.item.input_audio_transcription.completed`. item_id: type: string description: The ID of the user message item containing the audio. @@ -10116,8 +10826,16 @@ components: allOf: - $ref: '#/components/schemas/RealtimeServerEvent' description: |- - This event is the output of audio transcription for user audio written to the user audio buffer. Transcription begins when the input audio buffer is committed by the client or server (in `server_vad` mode). Transcription runs asynchronously with Response creation, so this event may come before or after the Response events. - Realtime API models accept audio natively, and thus input transcription is a separate process run on a separate ASR (Automatic Speech Recognition) model, currently always `whisper-1`. Thus the transcript may diverge somewhat from the model's interpretation, and should be treated as a rough guide. + This event is the output of audio transcription for user audio written to the + user audio buffer. Transcription begins when the input audio buffer is + committed by the client or server (in `server_vad` mode). Transcription runs + asynchronously with Response creation, so this event may come before or after + the Response events. + + Realtime API models accept audio natively, and thus input transcription is a + separate process run on a separate ASR (Automatic Speech Recognition) model, + currently always `whisper-1`. Thus the transcript may diverge somewhat from + the model's interpretation, and should be treated as a rough guide. RealtimeServerEventConversationItemInputAudioTranscriptionFailed: type: object required: @@ -10130,7 +10848,9 @@ components: type: string enum: - conversation.item.input_audio_transcription.failed - description: The event type, must be `conversation.item.input_audio_transcription.failed`. + description: |- + The event type, must be + `conversation.item.input_audio_transcription.failed`. item_id: type: string description: The ID of the user message item. @@ -10156,7 +10876,10 @@ components: description: Details of the transcription error. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when input audio transcription is configured, and a transcription request for a user message failed. These events are separate from other `error` events so that the client can identify the related Item. + description: |- + Returned when input audio transcription is configured, and a transcription + request for a user message failed. These events are separate from other + `error` events so that the client can identify the related Item. RealtimeServerEventConversationItemTruncated: type: object required: @@ -10184,8 +10907,12 @@ components: allOf: - $ref: '#/components/schemas/RealtimeServerEvent' description: |- - Returned when an earlier assistant audio message item is truncated by the client with a `conversation.item.truncate` event. This event is used to synchronize the server's understanding of the audio with the client's playback. - This action will truncate the audio and remove the server-side text transcript to ensure there is no text in the context that hasn't been heard by the user. + Returned when an earlier assistant audio message item is truncated by the + client with a `conversation.item.truncate` event. This event is used to + synchronize the server's understanding of the audio with the client's playback. + + This action will truncate the audio and remove the server-side text transcript + to ensure there is no text in the context that hasn't been heard by the user. RealtimeServerEventError: type: object required: @@ -10196,7 +10923,7 @@ components: type: string enum: - error - description: The event type, must be "error". + description: The event type, must be `error`. error: type: object properties: @@ -10205,20 +10932,29 @@ components: description: The type of error (e.g., "invalid_request_error", "server_error"). code: type: string + nullable: true description: Error code, if any. message: type: string description: A human-readable error message. param: type: string + nullable: true description: Parameter related to the error, if any. event_id: type: string + nullable: true description: The event_id of the client event that caused the error, if applicable. + required: + - type + - message description: Details of the error. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when an error occurs, which could be a client problem or a server problem. Most errors are recoverable and the session will stay open, we recommend to implementors to monitor and log error messages by default. + description: |- + Returned when an error occurs, which could be a client problem or a server + problem. Most errors are recoverable and the session will stay open, we + recommend to implementors to monitor and log error messages by default. RealtimeServerEventInputAudioBufferCleared: type: object required: @@ -10231,7 +10967,9 @@ components: description: The event type, must be `input_audio_buffer.cleared`. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when the input audio buffer is cleared by the client with a `input_audio_buffer.clear` event. + description: |- + Returned when the input audio buffer is cleared by the client with a + `input_audio_buffer.clear` event. RealtimeServerEventInputAudioBufferCommitted: type: object required: @@ -10252,7 +10990,11 @@ components: description: The ID of the user message item that will be created. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. The `item_id` property is the ID of the user message item that will be created, thus a `conversation.item.created` event will also be sent to the client. + description: |- + Returned when an input audio buffer is committed, either by the client or + automatically in server VAD mode. The `item_id` property is the ID of the user + message item that will be created, thus a `conversation.item.created` event + will also be sent to the client. RealtimeServerEventInputAudioBufferSpeechStarted: type: object required: @@ -10268,13 +11010,27 @@ components: audio_start_ms: type: integer format: int32 - description: Milliseconds from the start of all audio written to the buffer during the session when speech was first detected. This will correspond to the beginning of audio sent to the model, and thus includes the `prefix_padding_ms` configured in the Session. + description: |- + Milliseconds from the start of all audio written to the buffer during the + session when speech was first detected. This will correspond to the + beginning of audio sent to the model, and thus includes the + `prefix_padding_ms` configured in the Session. item_id: type: string description: The ID of the user message item that will be created when speech stops. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Sent by the server when in `server_vad` mode to indicate that speech has been detected in the audio buffer. This can happen any time audio is added to the buffer (unless speech is already detected). The client may want to use this event to interrupt audio playback or provide visual feedback to the user. The client should expect to receive a `input_audio_buffer.speech_stopped` event when speech stops. The `item_id` property is the ID of the user message item that will be created when speech stops and will also be included in the `input_audio_buffer.speech_stopped` event (unless the client manually commits the audio buffer during VAD activation). + description: |- + Sent by the server when in `server_vad` mode to indicate that speech has been + detected in the audio buffer. This can happen any time audio is added to the + buffer (unless speech is already detected). The client may want to use this + event to interrupt audio playback or provide visual feedback to the user. + + The client should expect to receive a `input_audio_buffer.speech_stopped` event + when speech stops. The `item_id` property is the ID of the user message item + that will be created when speech stops and will also be included in the + `input_audio_buffer.speech_stopped` event (unless the client manually commits + the audio buffer during VAD activation). RealtimeServerEventInputAudioBufferSpeechStopped: type: object required: @@ -10290,13 +11046,19 @@ components: audio_end_ms: type: integer format: int32 - description: Milliseconds since the session started when speech stopped. This will correspond to the end of audio sent to the model, and thus includes the `min_silence_duration_ms` configured in the Session. + description: |- + Milliseconds since the session started when speech stopped. This will + correspond to the end of audio sent to the model, and thus includes the + `min_silence_duration_ms` configured in the Session. item_id: type: string description: The ID of the user message item that will be created. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned in `server_vad` mode when the server detects the end of speech in the audio buffer. The server will also send an `conversation.item.created` event with the user message item that is created from the audio buffer. + description: |- + Returned in `server_vad` mode when the server detects the end of speech in + the audio buffer. The server will also send an `conversation.item.created` + event with the user message item that is created from the audio buffer. RealtimeServerEventRateLimitsUpdated: type: object required: @@ -10315,7 +11077,11 @@ components: description: List of rate limit information. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Emitted at the beginning of a Response to indicate the updated rate limits. When a Response is created some tokens will be "reserved" for the output tokens, the rate limits shown here reflect that reservation, which is then adjusted accordingly once the Response is completed. + description: |- + Emitted at the beginning of a Response to indicate the updated rate limits. + When a Response is created some tokens will be "reserved" for the output + tokens, the rate limits shown here reflect that reservation, which is then + adjusted accordingly once the Response is completed. RealtimeServerEventRateLimitsUpdatedRateLimitsItem: type: object required: @@ -10353,7 +11119,7 @@ components: type: string enum: - response.audio.delta - description: The event type, must be "response.audio.delta". + description: The event type, must be `response.audio.delta`. response_id: type: string description: The ID of the response. @@ -10388,7 +11154,7 @@ components: type: string enum: - response.audio.done - description: The event type, must be "response.audio.done". + description: The event type, must be `response.audio.done`. response_id: type: string description: The ID of the response. @@ -10405,7 +11171,9 @@ components: description: The index of the content part in the item's content array. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when the model-generated audio is done. Also emitted when a Response is interrupted, incomplete, or cancelled. + description: |- + Returned when the model-generated audio is done. Also emitted when a Response + is interrupted, incomplete, or cancelled. RealtimeServerEventResponseAudioTranscriptDelta: type: object required: @@ -10420,7 +11188,7 @@ components: type: string enum: - response.audio_transcript.delta - description: The event type, must be "response.audio_transcript.delta". + description: The event type, must be `response.audio_transcript.delta`. response_id: type: string description: The ID of the response. @@ -10455,7 +11223,7 @@ components: type: string enum: - response.audio_transcript.done - description: The event type, must be "response.audio_transcript.done". + description: The event type, must be `response.audio_transcript.done`. response_id: type: string description: The ID of the response. @@ -10475,7 +11243,10 @@ components: description: The final transcript of the audio. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when the model-generated transcription of audio output is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. + description: |- + Returned when the model-generated transcription of audio output is done + streaming. Also emitted when a Response is interrupted, incomplete, or + cancelled. RealtimeServerEventResponseContentPartAdded: type: object required: @@ -10490,7 +11261,7 @@ components: type: string enum: - response.content_part.added - description: The event type, must be "response.content_part.added". + description: The event type, must be `response.content_part.added`. response_id: type: string description: The ID of the response. @@ -10511,7 +11282,9 @@ components: description: The content part that was added. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a new content part is added to an assistant message item during response generation. + description: |- + Returned when a new content part is added to an assistant message item during + response generation. RealtimeServerEventResponseContentPartDone: type: object required: @@ -10526,7 +11299,7 @@ components: type: string enum: - response.content_part.done - description: The event type, must be "response.content_part.done". + description: The event type, must be `response.content_part.done`. response_id: type: string description: The ID of the response. @@ -10547,7 +11320,9 @@ components: description: The content part that is done. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a content part is done streaming in an assistant message item. Also emitted when a Response is interrupted, incomplete, or cancelled. + description: |- + Returned when a content part is done streaming in an assistant message item. + Also emitted when a Response is interrupted, incomplete, or cancelled. RealtimeServerEventResponseCreated: type: object required: @@ -10563,7 +11338,9 @@ components: $ref: '#/components/schemas/RealtimeResponse' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a new Response is created. The first event of response creation, where the response is in an initial state of `in_progress`. + description: |- + Returned when a new Response is created. The first event of response creation, + where the response is in an initial state of `in_progress`. RealtimeServerEventResponseDone: type: object required: @@ -10574,12 +11351,15 @@ components: type: string enum: - response.done - description: The event type, must be "response.done". + description: The event type, must be `response.done`. response: $ref: '#/components/schemas/RealtimeResponse' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a Response is done streaming. Always emitted, no matter the final state. The Response object included in the `response.done` event will include all output Items in the Response but will omit the raw audio data. + description: |- + Returned when a Response is done streaming. Always emitted, no matter the + final state. The Response object included in the `response.done` event will + include all output Items in the Response but will omit the raw audio data. RealtimeServerEventResponseFunctionCallArgumentsDelta: type: object required: @@ -10594,7 +11374,7 @@ components: type: string enum: - response.function_call_arguments.delta - description: The event type, must be "response.function_call_arguments.delta". + description: The event type, must be `response.function_call_arguments.delta`. response_id: type: string description: The ID of the response. @@ -10628,7 +11408,7 @@ components: type: string enum: - response.function_call_arguments.done - description: The event type, must be "response.function_call_arguments.done". + description: The event type, must be `response.function_call_arguments.done`. response_id: type: string description: The ID of the response. @@ -10647,7 +11427,9 @@ components: description: The final arguments as a JSON string. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when the model-generated function call arguments are done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. + description: |- + Returned when the model-generated function call arguments are done streaming. + Also emitted when a Response is interrupted, incomplete, or cancelled. RealtimeServerEventResponseOutputItemAdded: type: object required: @@ -10697,7 +11479,9 @@ components: $ref: '#/components/schemas/RealtimeConversationResponseItem' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. + description: |- + Returned when an Item is done streaming. Also emitted when a Response is + interrupted, incomplete, or cancelled. RealtimeServerEventResponseTextDelta: type: object required: @@ -10712,7 +11496,7 @@ components: type: string enum: - response.text.delta - description: The event type, must be "response.text.delta". + description: The event type, must be `response.text.delta`. response_id: type: string description: The ID of the response. @@ -10747,7 +11531,7 @@ components: type: string enum: - response.text.done - description: The event type, must be "response.text.done". + description: The event type, must be `response.text.done`. response_id: type: string description: The ID of the response. @@ -10767,7 +11551,9 @@ components: description: The final text content. allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when the text value of a "text" content part is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. + description: |- + Returned when the text value of a "text" content part is done streaming. Also + emitted when a Response is interrupted, incomplete, or cancelled. RealtimeServerEventSessionCreated: type: object required: @@ -10783,7 +11569,10 @@ components: $ref: '#/components/schemas/RealtimeResponseSession' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a Session is created. Emitted automatically when a new connection is established as the first server event. This event will contain the default Session configuration. + description: |- + Returned when a Session is created. Emitted automatically when a new + connection is established as the first server event. This event will contain + the default Session configuration. RealtimeServerEventSessionUpdated: type: object required: @@ -10794,12 +11583,14 @@ components: type: string enum: - session.updated - description: The event type, must be "session.updated". + description: The event type, must be `session.updated`. session: $ref: '#/components/schemas/RealtimeResponseSession' allOf: - $ref: '#/components/schemas/RealtimeServerEvent' - description: Returned when a session is updated with a `session.update` event, unless there is an error. + description: |- + Returned when a session is updated with a `session.update` event, unless + there is an error. RealtimeServerEventType: anyOf: - type: string @@ -10840,23 +11631,282 @@ components: properties: type: type: string - enum: - - server_vad - threshold: + enum: + - server_vad + threshold: + type: number + format: float + default: 0.5 + prefix_padding_ms: + type: string + format: duration + silence_duration_ms: + type: string + format: duration + allOf: + - $ref: '#/components/schemas/RealtimeTurnDetection' + RealtimeSessionBase: + type: object + description: Realtime session object configuration. + RealtimeSessionCreateRequest: + type: object + required: + - model + properties: + modalities: + type: array + items: + $ref: '#/components/schemas/RealtimeModality' + description: |- + The set of modalities the model can respond with. To disable audio, + set this to ["text"]. + model: + type: string + enum: + - gpt-4o-realtime-preview + - gpt-4o-realtime-preview-2024-10-01 + - gpt-4o-realtime-preview-2024-12-17 + - gpt-4o-mini-realtime-preview + - gpt-4o-mini-realtime-preview-2024-12-17 + description: The Realtime model used for this session. + instructions: + type: string + description: |- + The default system instructions (i.e. system message) prepended to model + calls. This field allows the client to guide the model on desired + responses. The model can be instructed on response content and format, + (e.g. "be extremely succinct", "act friendly", "here are examples of good + responses") and on audio behavior (e.g. "talk quickly", "inject emotion + into your voice", "laugh frequently"). The instructions are not guaranteed + to be followed by the model, but they provide guidance to the model on the + desired behavior. + + Note that the server sets default instructions which will be used if this + field is not set and are visible in the `session.created` event at the + start of the session. + voice: + allOf: + - $ref: '#/components/schemas/RealtimeVoice' + description: |- + The voice the model uses to respond. Voice cannot be changed during the + session once the model has responded with audio at least once. Current + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + `shimmer` and `verse`. + input_audio_format: + allOf: + - $ref: '#/components/schemas/RealtimeAudioFormat' + description: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + output_audio_format: + allOf: + - $ref: '#/components/schemas/RealtimeAudioFormat' + description: The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + input_audio_transcription: + type: object + properties: + model: + type: string + description: |- + The model to use for transcription, `whisper-1` is the only currently + supported model. + description: |- + Configuration for input audio transcription, defaults to off and can be + set to `null` to turn off once on. Input audio transcription is not native + to the model, since the model consumes audio directly. Transcription runs + asynchronously through Whisper and should be treated as rough guidance + rather than the representation understood by the model. + turn_detection: + type: object + properties: + type: + type: string + description: Type of turn detection, only `server_vad` is currently supported. + threshold: + type: number + format: float + description: |- + Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A + higher threshold will require louder audio to activate the model, and + thus might perform better in noisy environments. + prefix_padding_ms: + type: integer + format: int32 + description: |- + Amount of audio to include before the VAD detected speech (in + milliseconds). Defaults to 300ms. + silence_duration_ms: + type: integer + format: int32 + description: |- + Duration of silence to detect speech stop (in milliseconds). Defaults + to 500ms. With shorter values the model will respond more quickly, + but may jump in on short pauses from the user. + create_response: + type: boolean + description: |- + Whether or not to automatically generate a response when VAD is + enabled. `true` by default. + default: true + description: |- + Configuration for turn detection. Can be set to `null` to turn off. Server + VAD means that the model will detect the start and end of speech based on + audio volume and respond at the end of user speech. + tools: + type: array + items: + $ref: '#/components/schemas/RealtimeTool' + description: Tools (functions) available to the model. + tool_choice: + type: string + description: |- + How the model chooses tools. Options are `auto`, `none`, `required`, or + specify a function. + temperature: + type: number + format: float + description: Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. + max_response_output_tokens: + anyOf: + - type: integer + format: int32 + - type: string + enum: + - inf + description: |- + Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. + description: Realtime session object configuration. + RealtimeSessionCreateResponse: + type: object + properties: + client_secret: + type: object + properties: + value: + type: string + description: |- + Ephemeral key usable in client environments to authenticate connections + to the Realtime API. Use this in client-side environments rather than + a standard API token, which should only be used server-side. + expires_at: + type: integer + format: unixtime + description: |- + Timestamp for when the token expires. Currently, all tokens expire + after one minute. + description: Ephemeral key returned by the API. + modalities: + type: array + items: + $ref: '#/components/schemas/RealtimeModality' + description: |- + The set of modalities the model can respond with. To disable audio, + set this to ["text"]. + instructions: + type: string + description: |- + The default system instructions (i.e. system message) prepended to model + calls. This field allows the client to guide the model on desired + responses. The model can be instructed on response content and format, + (e.g. "be extremely succinct", "act friendly", "here are examples of good + responses") and on audio behavior (e.g. "talk quickly", "inject emotion + into your voice", "laugh frequently"). The instructions are not guaranteed + to be followed by the model, but they provide guidance to the model on the + desired behavior. + + Note that the server sets default instructions which will be used if this + field is not set and are visible in the `session.created` event at the + start of the session. + voice: + allOf: + - $ref: '#/components/schemas/RealtimeVoice' + description: |- + The voice the model uses to respond. Voice cannot be changed during the + session once the model has responded with audio at least once. Current + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + `shimmer` and `verse`. + input_audio_format: + allOf: + - $ref: '#/components/schemas/RealtimeAudioFormat' + description: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + output_audio_format: + allOf: + - $ref: '#/components/schemas/RealtimeAudioFormat' + description: The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + input_audio_transcription: + type: object + properties: + model: + type: string + description: |- + The model to use for transcription, `whisper-1` is the only currently + supported model. + description: |- + Configuration for input audio transcription, defaults to off and can be + set to `null` to turn off once on. Input audio transcription is not native + to the model, since the model consumes audio directly. Transcription runs + asynchronously through Whisper and should be treated as rough guidance + rather than the representation understood by the model. + turn_detection: + type: object + properties: + type: + type: string + description: Type of turn detection, only `server_vad` is currently supported. + threshold: + type: number + format: float + description: |- + Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A + higher threshold will require louder audio to activate the model, and + thus might perform better in noisy environments. + prefix_padding_ms: + type: integer + format: int32 + description: |- + Amount of audio to include before the VAD detected speech (in + milliseconds). Defaults to 300ms. + silence_duration_ms: + type: integer + format: int32 + description: |- + Duration of silence to detect speech stop (in milliseconds). Defaults + to 500ms. With shorter values the model will respond more quickly, + but may jump in on short pauses from the user. + description: |- + Configuration for turn detection. Can be set to `null` to turn off. Server + VAD means that the model will detect the start and end of speech based on + audio volume and respond at the end of user speech. + tools: + type: array + items: + $ref: '#/components/schemas/RealtimeTool' + description: Tools (functions) available to the model. + tool_choice: + type: string + description: |- + How the model chooses tools. Options are `auto`, `none`, `required`, or + specify a function. + temperature: type: number format: float - default: 0.5 - prefix_padding_ms: - type: string - format: duration - silence_duration_ms: - type: string - format: duration - allOf: - - $ref: '#/components/schemas/RealtimeTurnDetection' - RealtimeSessionBase: - type: object - description: Realtime session object configuration. + description: Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. + max_response_output_tokens: + anyOf: + - type: integer + format: int32 + - type: string + enum: + - inf + description: |- + Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. + description: |- + A new Realtime session configuration, with an ephermeral key. Default TTL + for keys is one minute. RealtimeTool: type: object required: @@ -10949,8 +11999,13 @@ components: - type: string enum: - alloy - - shimmer + - ash + - ballad + - coral - echo + - sage + - shimmer + - verse ResponseFormatJsonObject: type: object required: @@ -11427,15 +12482,7 @@ components: description: The type of tool call. This is always going to be `file_search` for this type of tool call. file_search: type: object - properties: - ranking_options: - $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchRankingOptionsObject' - results: - type: array - items: - $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchResultObject' - description: The results of the file search. - readOnly: true + additionalProperties: {} description: For now, this is always going to be an empty object. x-oaiTypeLabel: map allOf: @@ -11541,9 +12588,13 @@ components: RunStepDetailsToolCallsCodeObject: type: object required: + - id - type - code_interpreter properties: + id: + type: string + description: The ID of the tool call. type: type: string enum: @@ -11624,9 +12675,13 @@ components: RunStepDetailsToolCallsFileSearchObject: type: object required: + - id - type - file_search properties: + id: + type: string + description: The ID of the tool call object. type: type: string enum: @@ -11697,8 +12752,6 @@ components: text: type: string description: The text content of the file. - required: - - type description: The content of the result that was found. The content is only included if requested via the include query parameter. readOnly: true description: A result instance of the file search. @@ -11706,9 +12759,13 @@ components: RunStepDetailsToolCallsFunctionObject: type: object required: + - id - type - function properties: + id: + type: string + description: The ID of the tool call object. type: type: string enum: @@ -12334,6 +13391,340 @@ components: - upload.part description: The object type, which is always `upload.part`. description: The upload Part represents a chunk of bytes we can add to an Upload object. + UsageAudioSpeechesResult: + type: object + required: + - object + - characters + - num_model_requests + properties: + object: + type: string + enum: + - organization.usage.audio_speeches.result + characters: + type: integer + format: int32 + description: The number of characters processed. + num_model_requests: + type: integer + format: int32 + description: The count of requests made to the model. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the grouped usage result. + description: The aggregated audio speeches usage details of the specific time bucket. + UsageAudioTranscriptionsResult: + type: object + required: + - object + - seconds + - num_model_requests + properties: + object: + type: string + enum: + - organization.usage.audio_transcriptions.result + seconds: + type: integer + format: int32 + description: The number of seconds processed. + num_model_requests: + type: integer + format: int32 + description: The count of requests made to the model. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the grouped usage result. + description: The aggregated audio transcriptions usage details of the specific time bucket. + UsageCodeInterpreterSessionsResult: + type: object + required: + - object + - sessions + properties: + object: + type: string + enum: + - organization.usage.code_interpreter_sessions.result + sessions: + type: integer + format: int32 + description: The number of code interpreter sessions. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + description: The aggregated code interpreter sessions usage details of the specific time bucket. + UsageCompletionsResult: + type: object + required: + - object + - input_tokens + - output_tokens + - num_model_requests + properties: + object: + type: string + enum: + - organization.usage.completions.result + input_tokens: + type: integer + format: int32 + description: The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. + input_cached_tokens: + type: integer + format: int32 + description: The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens. + output_tokens: + type: integer + format: int32 + description: The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens. + input_audio_tokens: + type: integer + format: int32 + description: The aggregated number of audio input tokens used, including cached tokens. + output_audio_tokens: + type: integer + format: int32 + description: The aggregated number of audio output tokens used. + num_model_requests: + type: integer + format: int32 + description: The count of requests made to the model. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the grouped usage result. + batch: + type: boolean + nullable: true + description: When `group_by=batch`, this field tells whether the grouped usage result is batch or not. + description: The aggregated completions usage details of the specific time bucket. + UsageEmbeddingsResult: + type: object + required: + - object + - input_tokens + - num_model_requests + properties: + object: + type: string + enum: + - organization.usage.embeddings.result + input_tokens: + type: integer + format: int32 + description: The aggregated number of input tokens used. + num_model_requests: + type: integer + format: int32 + description: The count of requests made to the model. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the grouped usage result. + description: The aggregated embeddings usage details of the specific time bucket. + UsageImagesResult: + type: object + required: + - object + - images + - num_model_requests + properties: + object: + type: string + enum: + - organization.usage.images.result + images: + type: integer + format: int32 + description: The number of images processed. + num_model_requests: + type: integer + format: int32 + description: The count of requests made to the model. + source: + type: string + nullable: true + description: When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`. + size: + type: string + nullable: true + description: When `group_by=size`, this field provides the image size of the grouped usage result. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the grouped usage result. + description: The aggregated images usage details of the specific time bucket. + UsageModerationsResult: + type: object + required: + - object + - input_tokens + - num_model_requests + properties: + object: + type: string + enum: + - organization.usage.moderations.result + input_tokens: + type: integer + format: int32 + description: The aggregated number of input tokens used. + num_model_requests: + type: integer + format: int32 + description: The count of requests made to the model. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the grouped usage result. + description: The aggregated moderations usage details of the specific time bucket. + UsageResponse: + type: object + required: + - object + - data + - has_more + - next_page + properties: + object: + type: string + enum: + - page + data: + type: array + items: + $ref: '#/components/schemas/UsageTimeBucket' + has_more: + type: boolean + next_page: + type: string + UsageTimeBucket: + type: object + required: + - object + - start_time + - end_time + - result + properties: + object: + type: string + enum: + - bucket + start_time: + type: integer + format: int32 + end_time: + type: integer + format: int32 + result: + type: array + items: + anyOf: + - $ref: '#/components/schemas/UsageCompletionsResult' + - $ref: '#/components/schemas/UsageEmbeddingsResult' + - $ref: '#/components/schemas/UsageModerationsResult' + - $ref: '#/components/schemas/UsageImagesResult' + - $ref: '#/components/schemas/UsageAudioSpeechesResult' + - $ref: '#/components/schemas/UsageAudioTranscriptionsResult' + - $ref: '#/components/schemas/UsageVectorStoresResult' + - $ref: '#/components/schemas/UsageCodeInterpreterSessionsResult' + - $ref: '#/components/schemas/CostsResult' + UsageVectorStoresResult: + type: object + required: + - object + - usage_bytes + properties: + object: + type: string + enum: + - organization.usage.vector_stores.result + usage_bytes: + type: integer + format: int32 + description: The vector stores usage in bytes. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + description: The aggregated vector stores usage details of the specific time bucket. User: type: object required: diff --git a/.scripts/Update-ClientModel.ps1 b/.scripts/Update-ClientModel.ps1 index 37fa62987..94ab14007 100644 --- a/.scripts/Update-ClientModel.ps1 +++ b/.scripts/Update-ClientModel.ps1 @@ -2,7 +2,7 @@ function Remove-MultipartFormDataBinaryContent { $root = Split-Path $PSScriptRoot -Parent - $filePath = Join-Path -Path $root -ChildPath ".dotnet\src\Generated\Internal\MultiPartFormDataBinaryContent.cs" + $filePath = Join-Path -Path $root -ChildPath ".dotnet/src/Generated/Internal/MultiPartFormDataBinaryContent.cs" $file = Get-ChildItem -Path $filePath Write-Output "Removing $($file.FullName)" @@ -12,7 +12,7 @@ function Remove-MultipartFormDataBinaryContent { function Remove-ChatMessageContentSerialization { $root = Split-Path $PSScriptRoot -Parent - $filePath = Join-Path -Path $root -ChildPath ".dotnet\src\Generated\Models\ChatMessageContent.Serialization.cs" + $filePath = Join-Path -Path $root -ChildPath ".dotnet/src/Generated/Models/ChatMessageContent.Serialization.cs" $file = Get-ChildItem -Path $filePath Write-Output "Removing $($file.FullName)" diff --git a/.typespec/administration/models.tsp b/.typespec/administration/models.tsp index f429a8929..e9c6c9061 100644 --- a/.typespec/administration/models.tsp +++ b/.typespec/administration/models.tsp @@ -75,6 +75,8 @@ union AuditLogEventType { "service_account.created", "service_account.updated", "service_account.deleted", + "rate_limit.updated", + "rate_limit.deleted", "user.added", "user.updated", "user.deleted", @@ -283,6 +285,45 @@ model AuditLog { id?: string; }; + @doc(""" + The details for events with this `type`. + """) + @encodedName("application/json", "rate_limit.updated") + rate_limit_updated?: { + /** The rate limit ID */ + id?: string; + + /** The payload used to update the rate limits. */ + changes_requested?: { + /** The maximum requests per minute. */ + max_requests_per_1_minute?: int32; + + /** The maximum tokens per minute. */ + max_tokens_per_1_minute?: int32; + + /** The maximum images per minute. Only relevant for certain models. */ + max_images_per_1_minute?: int32; + + /** The maximum audio megabytes per minute. Only relevant for certain models. */ + max_audio_megabytes_per_1_minute?: int32; + + /** The maximum requests per day. Only relevant for certain models. */ + max_requests_per_1_day?: int32; + + /** The maximum batch input tokens per day. Only relevant for certain models. */ + batch_1_day_max_input_tokens?: int32; + }; + }; + + @doc(""" + The details for events with this `type`. + """) + @encodedName("application/json", "rate_limit.deleted") + rate_limit_deleted?: { + /** The rate limit ID */ + id?: string; + }; + @doc(""" The details for events with this `type`. """) @@ -417,6 +458,15 @@ model Invite { /** The Unix timestamp (in seconds) of when the invite was accepted. */ @encode("unixTimestamp", int32) accepted_at?: utcDateTime; + + /** The projects that were granted membership upon acceptance of the invite. */ + projects?: { + /** Project's public ID */ + id?: string; + + /** Project membership role */ + role?: "member" | "owner"; + }[]; } model InviteListResponse { @@ -451,6 +501,15 @@ model InviteRequest { `owner` or `reader` """) role: "reader" | "owner"; + + /** An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. */ + projects?: { + /** Project's public ID */ + id: string; + + /** Project membership role */ + role: "member" | "owner"; + }[]; } model InviteDeleteResponse { @@ -746,3 +805,349 @@ model ProjectApiKeyDeleteResponse { id: string; deleted: boolean; } + +/** The aggregated costs details of the specific time bucket. */ +model CostsResult { + object: "organization.costs.result"; + + /** The monetary value in its associated currency. */ + amount?: { + /** The numeric value of the cost. */ + value?: float32; + + /** Lowercase ISO-4217 currency e.g. "usd" */ + currency?: string; + }; + + @doc(""" + When `group_by=line_item`, this field provides the line item of the grouped costs result. + """) + line_item?: string | null; + + @doc(""" + When `group_by=project_id`, this field provides the project ID of the grouped costs result. + """) + project_id?: string | null; +} + +/** Represents a project rate limit config. */ +model ProjectRateLimit { + @doc(""" + The object type, which is always `project.rate_limit` + """) + object: "project.rate_limit"; + + /** The identifier, which can be referenced in API endpoints. */ + id: string; + + /** The model this rate limit applies to. */ + `model`: string; + + /** The maximum requests per minute. */ + max_requests_per_1_minute: int32; + + /** The maximum tokens per minute. */ + max_tokens_per_1_minute: int32; + + /** The maximum images per minute. Only present for relevant models. */ + max_images_per_1_minute?: int32; + + /** The maximum audio megabytes per minute. Only present for relevant models. */ + max_audio_megabytes_per_1_minute?: int32; + + /** The maximum requests per day. Only present for relevant models. */ + max_requests_per_1_day?: int32; + + /** The maximum batch input tokens per day. Only present for relevant models. */ + batch_1_day_max_input_tokens?: int32; +} + +model ProjectRateLimitListResponse { + object: "list"; + data: ProjectRateLimit[]; + first_id: string; + last_id: string; + has_more: boolean; +} + +model ProjectRateLimitUpdateRequest { + /** The maximum requests per minute. */ + max_requests_per_1_minute?: int32; + + /** The maximum tokens per minute. */ + max_tokens_per_1_minute?: int32; + + /** The maximum images per minute. Only relevant for certain models. */ + max_images_per_1_minute?: int32; + + /** The maximum audio megabytes per minute. Only relevant for certain models. */ + max_audio_megabytes_per_1_minute?: int32; + + /** The maximum requests per day. Only relevant for certain models. */ + max_requests_per_1_day?: int32; + + /** The maximum batch input tokens per day. Only relevant for certain models. */ + batch_1_day_max_input_tokens?: int32; +} + +/** The aggregated audio speeches usage details of the specific time bucket. */ +model UsageAudioSpeechesResult { + object: "organization.usage.audio_speeches.result"; + + /** The number of characters processed. */ + characters: int32; + + /** The count of requests made to the model. */ + num_model_requests: int32; + + @doc(""" + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + """) + project_id?: string | null; + + @doc(""" + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + """) + user_id?: string | null; + + @doc(""" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + """) + api_key_id?: string | null; + + @doc(""" + When `group_by=model`, this field provides the model name of the grouped usage result. + """) + `model`?: string | null; +} + +/** The aggregated audio transcriptions usage details of the specific time bucket. */ +model UsageAudioTranscriptionsResult { + object: "organization.usage.audio_transcriptions.result"; + + /** The number of seconds processed. */ + seconds: int32; + + /** The count of requests made to the model. */ + num_model_requests: int32; + + @doc(""" + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + """) + project_id?: string | null; + + @doc(""" + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + """) + user_id?: string | null; + + @doc(""" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + """) + api_key_id?: string | null; + + @doc(""" + When `group_by=model`, this field provides the model name of the grouped usage result. + """) + `model`?: string | null; +} + +/** The aggregated code interpreter sessions usage details of the specific time bucket. */ +model UsageCodeInterpreterSessionsResult { + object: "organization.usage.code_interpreter_sessions.result"; + + /** The number of code interpreter sessions. */ + sessions: int32; + + @doc(""" + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + """) + project_id?: string | null; +} + +/** The aggregated completions usage details of the specific time bucket. */ +model UsageCompletionsResult { + object: "organization.usage.completions.result"; + + /** The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. */ + input_tokens: int32; + + /** The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens. */ + input_cached_tokens?: int32; + + /** The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens. */ + output_tokens: int32; + + /** The aggregated number of audio input tokens used, including cached tokens. */ + input_audio_tokens?: int32; + + /** The aggregated number of audio output tokens used. */ + output_audio_tokens?: int32; + + /** The count of requests made to the model. */ + num_model_requests: int32; + + @doc(""" + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + """) + project_id?: string | null; + + @doc(""" + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + """) + user_id?: string | null; + + @doc(""" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + """) + api_key_id?: string | null; + + @doc(""" + When `group_by=model`, this field provides the model name of the grouped usage result. + """) + `model`?: string | null; + + @doc(""" + When `group_by=batch`, this field tells whether the grouped usage result is batch or not. + """) + batch?: boolean | null; +} + +/** The aggregated embeddings usage details of the specific time bucket. */ +model UsageEmbeddingsResult { + object: "organization.usage.embeddings.result"; + + /** The aggregated number of input tokens used. */ + input_tokens: int32; + + /** The count of requests made to the model. */ + num_model_requests: int32; + + @doc(""" + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + """) + project_id?: string | null; + + @doc(""" + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + """) + user_id?: string | null; + + @doc(""" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + """) + api_key_id?: string | null; + + @doc(""" + When `group_by=model`, this field provides the model name of the grouped usage result. + """) + `model`?: string | null; +} + +/** The aggregated images usage details of the specific time bucket. */ +model UsageImagesResult { + object: "organization.usage.images.result"; + + /** The number of images processed. */ + images: int32; + + /** The count of requests made to the model. */ + num_model_requests: int32; + + @doc(""" + When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`. + """) + source?: string | null; + + @doc(""" + When `group_by=size`, this field provides the image size of the grouped usage result. + """) + size?: string | null; + + @doc(""" + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + """) + project_id?: string | null; + + @doc(""" + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + """) + user_id?: string | null; + + @doc(""" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + """) + api_key_id?: string | null; + + @doc(""" + When `group_by=model`, this field provides the model name of the grouped usage result. + """) + `model`?: string | null; +} + +/** The aggregated moderations usage details of the specific time bucket. */ +model UsageModerationsResult { + object: "organization.usage.moderations.result"; + + /** The aggregated number of input tokens used. */ + input_tokens: int32; + + /** The count of requests made to the model. */ + num_model_requests: int32; + + @doc(""" + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + """) + project_id?: string | null; + + @doc(""" + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + """) + user_id?: string | null; + + @doc(""" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + """) + api_key_id?: string | null; + + @doc(""" + When `group_by=model`, this field provides the model name of the grouped usage result. + """) + `model`?: string | null; +} + +model UsageResponse { + object: "page"; + data: UsageTimeBucket[]; + has_more: boolean; + next_page: string; +} + +model UsageTimeBucket { + object: "bucket"; + start_time: int32; + end_time: int32; + result: ( + | UsageCompletionsResult + | UsageEmbeddingsResult + | UsageModerationsResult + | UsageImagesResult + | UsageAudioSpeechesResult + | UsageAudioTranscriptionsResult + | UsageVectorStoresResult + | UsageCodeInterpreterSessionsResult + | CostsResult)[]; +} + +/** The aggregated vector stores usage details of the specific time bucket. */ +model UsageVectorStoresResult { + object: "organization.usage.vector_stores.result"; + + /** The vector stores usage in bytes. */ + usage_bytes: int32; + + @doc(""" + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + """) + project_id?: string | null; +} diff --git a/.typespec/assistants/models.tsp b/.typespec/assistants/models.tsp index 84cc29b5e..d2cf1554d 100644 --- a/.typespec/assistants/models.tsp +++ b/.typespec/assistants/models.tsp @@ -11,7 +11,7 @@ using TypeSpec.OpenAPI; namespace OpenAI; @doc(""" - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). @@ -28,11 +28,12 @@ union AssistantsApiResponseFormatOption { } model CreateAssistantRequest { - /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. */ + /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. */ @extension("x-oaiTypeLabel", "string") `model`: | string | "gpt-4o" + | "gpt-4o-2024-11-20" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-mini" @@ -115,7 +116,7 @@ model CreateAssistantRequest { } model ModifyAssistantRequest { - /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. */ + /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. */ `model`?: string; /** The name of the assistant. The maximum length is 256 characters. */ @@ -212,7 +213,7 @@ model AssistantToolsFileSearch extends AssistantToolDefinition { @doc(""" The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. """) @minValue(1) @maxValue(50) @@ -225,7 +226,7 @@ model AssistantToolsFileSearch extends AssistantToolDefinition { @doc(""" The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. """) model FileSearchRankingOptions { @doc(""" @@ -281,7 +282,7 @@ model AssistantObject { @maxLength(512) description: string | null; - /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. */ + /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. */ `model`: string; /** The system instructions that the assistant uses. The maximum length is 256,000 characters. */ diff --git a/.typespec/audio/models.tsp b/.typespec/audio/models.tsp index a4775f2a4..83f843391 100644 --- a/.typespec/audio/models.tsp +++ b/.typespec/audio/models.tsp @@ -22,7 +22,7 @@ union AudioResponseFormat { model CreateSpeechRequest { @doc(""" - One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd` + One of the available [TTS models](/docs/models#tts): `tts-1` or `tts-1-hd` """) @extension("x-oaiTypeLabel", "string") `model`: string | "tts-1" | "tts-1-hd"; @@ -32,9 +32,18 @@ model CreateSpeechRequest { input: string; @doc(""" - The voice to use when generating the audio. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech/voice-options). + The voice to use when generating the audio. Supported voices are `alloy`, `ash`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech#voice-options). """) - voice: "alloy" | "echo" | "fable" | "onyx" | "nova" | "shimmer"; + voice: + | "alloy" + | "ash" + | "coral" + | "echo" + | "fable" + | "onyx" + | "nova" + | "sage" + | "shimmer"; @doc(""" The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`. @@ -63,7 +72,7 @@ model CreateTranscriptionRequest { /** The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. */ language?: string; - /** An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. */ + /** An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should match the audio language. */ prompt?: string; // Tool customization: use scenario-specific composed union @@ -92,7 +101,7 @@ model CreateTranslationRequest { @extension("x-oaiTypeLabel", "string") `model`: string | "whisper-1"; - /** An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. */ + /** An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should be in English. */ prompt?: string; // Tool customization: use scenario-specific composed union diff --git a/.typespec/chat/models.tsp b/.typespec/chat/models.tsp index 7563d5fe5..57b0e6296 100644 --- a/.typespec/chat/models.tsp +++ b/.typespec/chat/models.tsp @@ -23,21 +23,25 @@ model CreateChatCompletionRequest { @minItems(1) messages: ChatCompletionRequestMessage[]; - /** ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. */ + /** ID of the model to use. See the [model endpoint compatibility](/docs/models#model-endpoint-compatibility) table for details on which models work with the Chat API. */ @extension("x-oaiTypeLabel", "string") `model`: | string + | "o1" + | "o1-2024-12-17" | "o1-preview" | "o1-preview-2024-09-12" | "o1-mini" | "o1-mini-2024-09-12" | "gpt-4o" + | "gpt-4o-2024-11-20" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" - | "gpt-4o-realtime-preview" - | "gpt-4o-realtime-preview-2024-10-01" | "gpt-4o-audio-preview" | "gpt-4o-audio-preview-2024-10-01" + | "gpt-4o-audio-preview-2024-12-17" + | "gpt-4o-mini-audio-preview" + | "gpt-4o-mini-audio-preview-2024-12-17" | "chatgpt-4o-latest" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" @@ -62,11 +66,23 @@ model CreateChatCompletionRequest { | "gpt-3.5-turbo-16k-0613"; /** - * Whether or not to store the output of this chat completion request - * for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + * Whether or not to store the output of this chat completion request for + * use in our [model distillation](/docs/guides/distillation) or + * [evals](/docs/guides/evals) products. */ store?: boolean | null = false; + @doc(""" + **o1 models only** + + Constrains effort on reasoning for + [reasoning models](https://platform.openai.com/docs/guides/reasoning). + Currently supported values are `low`, `medium`, and `high`. Reducing + reasoning effort can result in faster responses and fewer tokens used + on reasoning in a response. + """) + reasoning_effort?: "low" | "medium" | "high" = "medium"; + /** * Developer-defined tags and values used for filtering completions * in the [dashboard](https://platform.openai.com/chat-completions). @@ -74,9 +90,9 @@ model CreateChatCompletionRequest { metadata?: Record | null; /** - * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - * - * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + * Number between -2.0 and 2.0. Positive values penalize new tokens based on + * their existing frequency in the text so far, decreasing the model's + * likelihood to repeat the same line verbatim. */ @minValue(-2) @maxValue(2) @@ -85,18 +101,27 @@ model CreateChatCompletionRequest { /** * Modify the likelihood of specified tokens appearing in the completion. * - * Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + * Accepts a JSON object that maps tokens (specified by their token ID in the + * tokenizer) to an associated bias value from -100 to 100. Mathematically, + * the bias is added to the logits generated by the model prior to sampling. + * The exact effect will vary per model, but values between -1 and 1 should + * decrease or increase likelihood of selection; values like -100 or 100 + * should result in a ban or exclusive selection of the relevant token. */ @extension("x-oaiTypeLabel", "map") logit_bias?: Record | null = null; @doc(""" - Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + Whether to return log probabilities of the output tokens or not. If true, + returns the log probabilities of each output token returned in the + `content` of `message`. """) logprobs?: boolean | null = false; @doc(""" - An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + An integer between 0 and 20 specifying the number of most likely tokens to + return at each token position, each with an associated log probability. + `logprobs` must be set to `true` if this parameter is used. """) @minValue(0) @maxValue(20) @@ -104,9 +129,12 @@ model CreateChatCompletionRequest { #deprecated "This field is marked as deprecated." @doc(""" - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + The maximum number of [tokens](/tokenizer) that can be generated in the + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + This value is now deprecated in favor of `max_completion_tokens`, and is + not compatible with [o1 series models](/docs/guides/reasoning). """) max_tokens?: int32 | null; @@ -122,6 +150,15 @@ model CreateChatCompletionRequest { modalities?: ChatCompletionModalities | null; + /** + * Configuration for a [Predicted Output](/docs/guides/predicted-outputs), + * which can greatly improve response times when large parts of the model + * response are known ahead of time. This is most common when you are + * regenerating a file with only minor changes to most of the content. + */ + @extension("x-oaiExpandable", true) + prediction?: PredictionContent | null; + @doc(""" Parameters for audio output. Required when audio output is requested with `modalities: ["audio"]`. [Learn more](/docs/guides/audio). @@ -129,10 +166,17 @@ model CreateChatCompletionRequest { @extension("x-oaiExpandable", true) audio?: { @doc(""" - Specifies the voice type. Supported voices are `alloy`, `echo`, - `fable`, `onyx`, `nova`, and `shimmer`. + The voice the model uses to respond. Supported voices are `ash`, `ballad`, `coral`, `sage`, and `verse` (also supported but not recommended are `alloy`, `echo`, and `shimmer`; these voices are less expressive). """) - voice: "alloy" | "echo" | "fable" | "onyx" | "nova" | "shimmer"; + voice: + | "alloy" + | "ash" + | "ballad" + | "coral" + | "echo" + | "sage" + | "shimmer" + | "verse"; @doc(""" Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, @@ -142,9 +186,9 @@ model CreateChatCompletionRequest { } | null; /** - * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - * - * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + * Number between -2.0 and 2.0. Positive values penalize new tokens based on + * whether they appear in the text so far, increasing the model's likelihood + * to talk about new topics. */ @minValue(-2) @maxValue(2) @@ -152,13 +196,23 @@ model CreateChatCompletionRequest { // Tool customization: apply a named union type @doc(""" - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + An object specifying the format that the model must output. - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + **Important:** when using JSON mode, you **must** also instruct the model + to produce JSON yourself via a system or user message. Without this, the + model may generate an unending stream of whitespace until the generation + reaches the token limit, resulting in a long-running and seemingly "stuck" + request. Also note that the message content may be partially cut off if + `finish_reason="length"`, which indicates the generation exceeded + `max_tokens` or the conversation exceeded the max context length. """) @extension("x-oaiExpandable", true) response_format?: ChatResponseFormat; @@ -174,7 +228,7 @@ model CreateChatCompletionRequest { @doc(""" Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. + - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - When not set, the default behavior is 'auto'. @@ -195,7 +249,6 @@ model CreateChatCompletionRequest { @doc(""" What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. """) @minValue(0) @@ -203,7 +256,10 @@ model CreateChatCompletionRequest { temperature?: float32 | null = 1; @doc(""" - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + An alternative to sampling with temperature, called nucleus sampling, + where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass + are considered. We generally recommend altering this or `temperature` but not both. """) @@ -217,7 +273,7 @@ model CreateChatCompletionRequest { tool_choice?: ChatCompletionToolChoiceOption; parallel_tool_calls?: ParallelToolCalls = true; - /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). */ + /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). */ user?: string; #deprecated "This field is marked as deprecated." @@ -225,11 +281,18 @@ model CreateChatCompletionRequest { Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - `none` is the default when no functions are present. `auto` is the default if functions are present. + `none` means the model will not call a function and instead generates a + message. + + `auto` means the model can pick between generating a message or calling a + function. + + Specifying a particular function via `{"name": "my_function"}` forces the + model to call that function. + + `none` is the default when no functions are present. `auto` is the default + if functions are present. """) @extension("x-oaiExpandable", true) function_call?: "none" | "auto" | ChatCompletionFunctionCallOption; @@ -369,7 +432,7 @@ model ChatCompletionRequestMessageContentPartImage { /** Either a URL of the image or the base64 encoded image data. */ url: url; - /** Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). */ + /** Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). */ detail?: "auto" | "low" | "high" = "auto"; }; } @@ -451,6 +514,11 @@ union ChatCompletionRequestToolMessageContentPart { } // Tool customization: apply discriminated type base +@doc(""" + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. + """) model ChatCompletionRequestSystemMessage extends ChatCompletionRequestMessage { /** The contents of the system message. */ content: string | ChatCompletionRequestSystemMessageContentPart[]; @@ -465,6 +533,30 @@ model ChatCompletionRequestSystemMessage extends ChatCompletionRequestMessage { } // Tool customization: apply discriminated type base +@doc(""" + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, `developer` messages + replace the previous `system` messages. + """) +model ChatCompletionRequestDeveloperMessage + extends ChatCompletionRequestMessage { + /** The contents of the developer message. */ + content: string | ChatCompletionRequestMessageContentPartText[]; + + @doc(""" + The role of the messages author, in this case `developer`. + """) + role: "developer"; + + /** An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ + name?: string; +} + +// Tool customization: apply discriminated type base +/** + * Messages sent by an end user, containing prompts or additional context + * information. + */ model ChatCompletionRequestUserMessage extends ChatCompletionRequestMessage { /** The contents of the user message. */ @extension("x-oaiExpandable", true) @@ -480,6 +572,7 @@ model ChatCompletionRequestUserMessage extends ChatCompletionRequestMessage { } // Tool customization: apply discriminated type base +/** Messages sent by the model in response to user messages. */ model ChatCompletionRequestAssistantMessage extends ChatCompletionRequestMessage { @doc(""" @@ -569,10 +662,11 @@ model ChatCompletionMessageToolCalls is ChatCompletionMessageToolCall[]; """) model ChatCompletionModalities is ("text" | "audio")[]; -// Tool customization: convert to enum +// Tool customization: convert to enum (and add developer) /** The role of the author of a message */ enum ChatCompletionRole { system, + developer, user, assistant, tool, @@ -860,3 +954,23 @@ model CreateChatCompletionStreamResponse { /** Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ alias CreateChatCompletionImageResponse = unknown; + +/** + * Static predicted output content, such as the content of a text file that is + * being regenerated. + */ +model PredictionContent { + @doc(""" + The type of the predicted content you want to provide. This type is + currently always `content`. + """) + type: "content"; + + /** + * The content that should be matched when generating a model response. + * If generated tokens would match this content, the entire model response + * can be returned much more quickly. + */ + @extension("x-oaiExpandable", true) + content: string | ChatCompletionRequestMessageContentPartText[]; +} diff --git a/.typespec/common/models.tsp b/.typespec/common/models.tsp index 42643d9c2..9ad1b630e 100644 --- a/.typespec/common/models.tsp +++ b/.typespec/common/models.tsp @@ -86,7 +86,7 @@ model ResponseFormatJsonSchema extends OmniTypedResponseFormat { }; } -/** Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. */ +/** Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. */ alias ParallelToolCalls = boolean; /** Usage statistics for the completion request. */ @@ -102,20 +102,35 @@ model CompletionUsage { /** Breakdown of tokens used in a completion. */ completion_tokens_details?: { + /** + * When using Predicted Outputs, the number of tokens in the + * prediction that appeared in the completion. + */ + accepted_prediction_tokens?: int32; + /** Audio input tokens generated by the model. */ - audio_tokens: int32; + audio_tokens?: int32; /** Tokens generated by the model for reasoning. */ - reasoning_tokens: int32; + reasoning_tokens?: int32; + + /** + * When using Predicted Outputs, the number of tokens in the + * prediction that did not appear in the completion. However, like + * reasoning tokens, these tokens are still counted in the total + * completion tokens for purposes of billing, output, and context window + * limits. + */ + rejected_prediction_tokens?: int32; }; /** Breakdown of tokens used in the prompt. */ prompt_tokens_details?: { /** Audio input tokens present in the prompt. */ - audio_tokens: int32; + audio_tokens?: int32; /** Cached tokens present in the prompt. */ - cached_tokens: int32; + cached_tokens?: int32; }; } diff --git a/.typespec/completions/models.tsp b/.typespec/completions/models.tsp index f6276c540..8417de0c2 100644 --- a/.typespec/completions/models.tsp +++ b/.typespec/completions/models.tsp @@ -10,7 +10,7 @@ using TypeSpec.OpenAPI; namespace OpenAI; model CreateCompletionRequest { - /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. */ + /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. */ @extension("x-oaiTypeLabel", "string") `model`: string | "gpt-3.5-turbo-instruct" | "davinci-002" | "babbage-002"; @@ -38,7 +38,7 @@ model CreateCompletionRequest { /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. * - * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + * [See more information about frequency and presence penalties.](/docs/guides/text-generation) */ @minValue(-2) @maxValue(2) @@ -83,7 +83,7 @@ model CreateCompletionRequest { /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. * - * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + * [See more information about frequency and presence penalties.](/docs/guides/text-generation) */ @minValue(-2) @maxValue(2) @@ -133,7 +133,7 @@ model CreateCompletionRequest { @maxValue(1) top_p?: float32 | null = 1; - /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). */ + /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). */ user?: string; } diff --git a/.typespec/embeddings/models.tsp b/.typespec/embeddings/models.tsp index 7d391ad34..ed0623b58 100644 --- a/.typespec/embeddings/models.tsp +++ b/.typespec/embeddings/models.tsp @@ -9,12 +9,12 @@ namespace OpenAI; model CreateEmbeddingRequest { @doc(""" - Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. + Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. Some models may also impose a limit on total number of tokens summed across inputs. """) @extension("x-oaiExpandable", true) input: string | string[] | int32[] | int32[][]; - /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. */ + /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. */ @extension("x-oaiTypeLabel", "string") `model`: | string @@ -33,7 +33,7 @@ model CreateEmbeddingRequest { @minValue(1) dimensions?: int32; - /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). */ + /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). */ user?: string; } diff --git a/.typespec/files/models.tsp b/.typespec/files/models.tsp index 40cb79c99..6656037e6 100644 --- a/.typespec/files/models.tsp +++ b/.typespec/files/models.tsp @@ -20,8 +20,11 @@ model CreateFileRequest { } model ListFilesResponse { + object: string; data: OpenAIFile[]; - object: "list"; + first_id: string; + last_id: string; + has_more: boolean; } model DeleteFileResponse { diff --git a/.typespec/fine-tuning/client.tsp b/.typespec/fine-tuning/client.tsp index 911876ab9..576a6aff8 100644 --- a/.typespec/fine-tuning/client.tsp +++ b/.typespec/fine-tuning/client.tsp @@ -4,8 +4,8 @@ import "./models.tsp"; using Azure.ClientGenerator.Core; using OpenAI; -@@access(FinetuneChatRequestInput, Access.public); -@@usage(FinetuneChatRequestInput, Usage.input); +@@access(FineTuneChatRequestInput, Access.public); +@@usage(FineTuneChatRequestInput, Usage.input); -@@access(FinetuneCompletionRequestInput, Access.public); -@@usage(FinetuneCompletionRequestInput, Usage.input); +@@access(FineTuneCompletionRequestInput, Access.public); +@@usage(FineTuneCompletionRequestInput, Usage.input); diff --git a/.typespec/fine-tuning/custom.tsp b/.typespec/fine-tuning/custom.tsp index eeacb518e..71cf5c411 100644 --- a/.typespec/fine-tuning/custom.tsp +++ b/.typespec/fine-tuning/custom.tsp @@ -2,31 +2,6 @@ using TypeSpec.OpenAPI; namespace OpenAI; -model CreateFineTuningJobRequestHyperparameters { - /** - * The number of epochs to train the model for. An epoch refers to one full cycle - * through the training dataset. - */ - @minValue(1) - @maxValue(50) - n_epochs?: CreateFineTuningJobRequestHyperparametersNEpochsChoiceEnum | int32 = CreateFineTuningJobRequestHyperparametersNEpochsChoiceEnum.auto; - - /** - * Number of examples in each batch. A larger batch size means that model parameters - * are updated less frequently, but with lower variance. - */ - @minValue(1) - @maxValue(256) - batch_size?: CreateFineTuningJobRequestHyperparametersBatchSizeChoiceEnum | int32 = CreateFineTuningJobRequestHyperparametersBatchSizeChoiceEnum.auto; - - /** - * Scaling factor for the learning rate. A smaller learning rate may be useful to avoid - * overfitting. - */ - @minValue(0) - learning_rate_multiplier?: CreateFineTuningJobRequestHyperparametersLearningRateMultiplierChoiceEnum | float32 = CreateFineTuningJobRequestHyperparametersLearningRateMultiplierChoiceEnum.auto; -} - union CreateFineTuningJobRequestHyperparametersBatchSizeChoiceEnum { auto: "auto", } @@ -37,26 +12,6 @@ union CreateFineTuningJobRequestHyperparametersNEpochsChoiceEnum { auto: "auto", } -model FineTuningJobHyperparameters { - /** - * The number of epochs to train the model for. An epoch refers to one full cycle - * through the training dataset. - */ - n_epochs: FineTuningJobHyperparametersNEpochsChoiceEnum | int32 = FineTuningJobHyperparametersNEpochsChoiceEnum.auto; - - /** - * Number of examples in each batch. A larger batch size means that model parameters - * are updated less frequently, but with lower variance. - */ - batch_size: FineTuningJobHyperparametersBatchSizeChoiceEnum | int32 = FineTuningJobHyperparametersBatchSizeChoiceEnum.auto; - - /** - * Scaling factor for the learning rate. A smaller learning rate may be useful to avoid - * overfitting. - */ - learning_rate_multiplier: FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum | float32 = FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum.auto; -} - union FineTuningJobHyperparametersBatchSizeChoiceEnum { auto: "auto", } diff --git a/.typespec/fine-tuning/models.tsp b/.typespec/fine-tuning/models.tsp index e9f81f0bc..d162e6526 100644 --- a/.typespec/fine-tuning/models.tsp +++ b/.typespec/fine-tuning/models.tsp @@ -23,7 +23,7 @@ model FineTuningJobIntegrations is FineTuningIntegration[]; model CreateFineTuningJobRequest { /** * The name of the model to fine-tune. You can select one of the - * [supported models](/docs/guides/fine-tuning/which-models-can-be-fine-tuned). + * [supported models](/docs/guides/fine-tuning#which-models-can-be-fine-tuned). */ @extension("x-oaiTypeLabel", "string") `model`: @@ -40,15 +40,36 @@ model CreateFineTuningJobRequest { Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`. - The contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) format. + The contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input), [completions](/docs/api-reference/fine-tuning/completions-input) format, or if the fine-tuning method uses the [preference](/docs/api-reference/fine-tuning/preference-input) format. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. """) training_file: string; - // Tool customization: reflect observed wire truth (learning_rate_multiplier, n_epochs) for hyperparameters in ft responses - /** The hyperparameters used for the fine-tuning job. */ - hyperparameters?: CreateFineTuningJobRequestHyperparameters; + #deprecated "This field is marked as deprecated." + @doc(""" + The hyperparameters used for the fine-tuning job. + This value is now deprecated in favor of `method`, and should be passed in under the `method` parameter. + """) + hyperparameters?: { + /** + * Number of examples in each batch. A larger batch size means that model parameters + * are updated less frequently, but with lower variance. + */ + batch_size?: "auto" | int32 = "auto"; + + /** + * Scaling factor for the learning rate. A smaller learning rate may be useful to avoid + * overfitting. + */ + learning_rate_multiplier?: "auto" | float32 = "auto"; + + /** + * The number of epochs to train the model for. An epoch refers to one full cycle + * through the training dataset. + */ + n_epochs?: "auto" | int32 = "auto"; + }; @doc(""" A string of up to 64 characters that will be added to your fine-tuned model name. @@ -84,6 +105,8 @@ model CreateFineTuningJobRequest { @minValue(0) @maxValue(2147483647) seed?: int32 | null; + + method?: FineTuneMethod; } model ListPaginatedFineTuningJobsResponse { @@ -147,9 +170,28 @@ model FineTuningJob { @encode("unixTimestamp", int32) finished_at: utcDateTime | null; - // Tool customization: reflect observed wire truth (learning_rate_multiplier, n_epochs) for hyperparameters in ft responses - /** The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. */ - hyperparameters: FineTuningJobHyperparameters; + @doc(""" + The hyperparameters used for the fine-tuning job. This value will only be returned when running `supervised` jobs. + """) + hyperparameters: { + /** + * Number of examples in each batch. A larger batch size means that model parameters + * are updated less frequently, but with lower variance. + */ + batch_size?: "auto" | int32 = "auto"; + + /** + * Scaling factor for the learning rate. A smaller learning rate may be useful to avoid + * overfitting. + */ + learning_rate_multiplier?: "auto" | float32 = "auto"; + + /** + * The number of epochs to train the model for. An epoch refers to one full cycle + * through the training dataset. + */ + n_epochs?: "auto" | int32 = "auto"; + }; /** The base model that is being fine-tuned. */ `model`: string; @@ -193,6 +235,8 @@ model FineTuningJob { /** The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running. */ @encode("unixTimestamp", int32) estimated_finish?: utcDateTime | null; + + method?: FineTuneMethod; } // Tool customization: Convert to instantiation of discriminated type @@ -228,15 +272,28 @@ model FineTuningIntegrationWandb extends FineTuningIntegration { /** Fine-tuning job event object */ model FineTuningJobEvent { + /** The object type, which is always "fine_tuning.job.event". */ + object: "fine_tuning.job.event"; + + /** The object identifier. */ id: string; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime + /** The Unix timestamp (in seconds) for when the fine-tuning job was created. */ @encode("unixTimestamp", int32) created_at: utcDateTime; + /** The log level of the event. */ level: "info" | "warn" | "error"; + + /** The message of the event. */ message: string; - object: "fine_tuning.job.event"; + + /** The type of event. */ + type?: "message" | "metrics"; + + /** The data associated with the event. */ + data?: unknown; } @doc(""" @@ -275,8 +332,11 @@ model FineTuningJobCheckpoint { object: "fine_tuning.job.checkpoint"; } -/** The per-line training example of a fine-tuning input file for chat models */ -model FinetuneChatRequestInput { +model FineTuneChatCompletionRequestAssistantMessage + extends ChatCompletionRequestAssistantMessage {} + +/** The per-line training example of a fine-tuning input file for chat models using the supervised method. */ +model FineTuneChatRequestInput { @minItems(1) @extension("x-oaiExpandable", true) messages?: ( @@ -299,7 +359,7 @@ model FinetuneChatRequestInput { } /** The per-line training example of a fine-tuning input file for completions models */ -model FinetuneCompletionRequestInput { +model FineTuneCompletionRequestInput { /** The input prompt for this training example. */ prompt?: string; @@ -307,5 +367,75 @@ model FinetuneCompletionRequestInput { completion?: string; } -model FineTuneChatCompletionRequestAssistantMessage - extends ChatCompletionRequestAssistantMessage {} +/** Configuration for the DPO fine-tuning method. */ +model FineTuneDPOMethod { + /** The hyperparameters used for the fine-tuning job. */ + hyperparameters?: { + /** The beta value for the DPO method. A higher beta value will increase the weight of the penalty between the policy and reference model. */ + beta?: "auto" | float32 = "auto"; + + /** Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance. */ + batch_size?: "auto" | int32 = "auto"; + + /** Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting. */ + learning_rate_multiplier?: "auto" | float32 = "auto"; + + /** The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. */ + n_epochs?: "auto" | int32 = "auto"; + }; +} + +/** The method used for fine-tuning. */ +model FineTuneMethod { + @doc(""" + The type of method. Is either `supervised` or `dpo`. + """) + type?: "supervised" | "dpo"; + + supervised?: FineTuneSupervisedMethod; + dpo?: FineTuneDPOMethod; +} + +/** The per-line training example of a fine-tuning input file for chat models using the dpo method. */ +model FineTunePreferenceRequestInput { + input?: { + @minItems(1) + @extension("x-oaiExpandable", true) + messages?: ( + | ChatCompletionRequestSystemMessage + | ChatCompletionRequestUserMessage + | FineTuneChatCompletionRequestAssistantMessage + | ChatCompletionRequestToolMessage + | ChatCompletionRequestFunctionMessage)[]; + + /** A list of tools the model may generate JSON inputs for. */ + tools?: ChatCompletionTool[]; + + parallel_tool_calls?: ParallelToolCalls = true; + }; + + /** The preferred completion message for the output. */ + @maxItems(1) + @extension("x-oaiExpandable", true) + preferred_completion?: ChatCompletionRequestAssistantMessage[]; + + /** The non-preferred completion message for the output. */ + @maxItems(1) + @extension("x-oaiExpandable", true) + non_preferred_completion?: ChatCompletionRequestAssistantMessage[]; +} + +/** Configuration for the supervised fine-tuning method. */ +model FineTuneSupervisedMethod { + /** The hyperparameters used for the fine-tuning job. */ + hyperparameters?: { + /** Number of examples in each batch. A larger batch size means that model parameters are updated less frequently, but with lower variance. */ + batch_size?: "auto" | int32 = "auto"; + + /** Scaling factor for the learning rate. A smaller learning rate may be useful to avoid overfitting. */ + learning_rate_multiplier?: "auto" | float32 = "auto"; + + /** The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. */ + n_epochs?: "auto" | int32 = "auto"; + }; +} diff --git a/.typespec/images/models.tsp b/.typespec/images/models.tsp index 5cf654ac5..3965e12dc 100644 --- a/.typespec/images/models.tsp +++ b/.typespec/images/models.tsp @@ -50,7 +50,7 @@ model CreateImageRequest { """) style?: "vivid" | "natural" | null = "vivid"; - /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). */ + /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). */ user?: string; } @@ -87,7 +87,7 @@ model CreateImageEditRequest { """) response_format?: "url" | "b64_json" | null = "url"; - /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). */ + /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). */ user?: string; } @@ -118,7 +118,7 @@ model CreateImageVariationRequest { """) size?: "256x256" | "512x512" | "1024x1024" | null = "1024x1024"; - /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). */ + /** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). */ user?: string; } diff --git a/.typespec/moderations/models.tsp b/.typespec/moderations/models.tsp index b1af3a7ca..2dfefb94d 100644 --- a/.typespec/moderations/models.tsp +++ b/.typespec/moderations/models.tsp @@ -39,7 +39,7 @@ model CreateModerationRequest { /** * The content moderation model you would like to use. Learn more in * [the moderation guide](/docs/guides/moderation), and learn about - * available models [here](/docs/models/moderation). + * available models [here](/docs/models#moderation). */ @extension("x-oaiTypeLabel", "string") `model`?: diff --git a/.typespec/organization/models.tsp b/.typespec/organization/models.tsp new file mode 100644 index 000000000..4bbb8edfa --- /dev/null +++ b/.typespec/organization/models.tsp @@ -0,0 +1,18 @@ +/* + * This file was automatically generated from an OpenAPI .yaml file. + * Edits made directly to this file will be lost. + */ + +import "../uploads"; + +using TypeSpec.OpenAPI; + +namespace OpenAI; + +model ApiKeyList { + object?: string; + data?: AdminApiKey[]; + has_more?: boolean; + first_id?: string; + last_id?: string; +} diff --git a/.typespec/realtime/client.tsp b/.typespec/realtime/client.tsp index ef914b0a4..2f3a21635 100644 --- a/.typespec/realtime/client.tsp +++ b/.typespec/realtime/client.tsp @@ -82,7 +82,6 @@ using OpenAI; @@clientName(RealtimeTurnDetection.type, "Kind", "csharp"); @@clientName(RealtimeServerVadTurnDetection.type, "Kind", "csharp"); @@clientName(RealtimeContentPart.type, "Kind", "csharp"); -@@clientName(RealtimeResponseStatusDetails.type, "Kind", "csharp"); @@visibility(RealtimeResponseMessageItem.content, "read"); @@visibility(RealtimeResponseSession.tools, "read"); diff --git a/.typespec/realtime/custom.tsp b/.typespec/realtime/custom.tsp index 3ce8eff8d..73d47fe9b 100644 --- a/.typespec/realtime/custom.tsp +++ b/.typespec/realtime/custom.tsp @@ -8,8 +8,15 @@ namespace OpenAI; model RealtimeRequestSession { ...RealtimeSessionBase; - modalities?: RealtimeModalities; + modalities?: RealtimeModality[]; instructions?: string; + `model`?: + | string + | "gpt-4o-realtime-preview" + | "gpt-4o-realtime-preview-2024-10-01" + | "gpt-4o-realtime-preview-2024-12-17" + | "gpt-4o-mini-realtime-preview" + | "gpt-4o-mini-realtime-preview-2024-12-17"; voice?: RealtimeVoice; input_audio_format?: RealtimeAudioFormat; output_audio_format?: RealtimeAudioFormat; @@ -26,7 +33,7 @@ model RealtimeResponseSession { object: "realtime.session"; id: string; `model`: string; - modalities: RealtimeModalities; + modalities: RealtimeModality[]; instructions: string; voice: RealtimeVoice; input_audio_format: RealtimeAudioFormat; @@ -39,65 +46,16 @@ model RealtimeResponseSession { max_response_output_tokens: int32 | "inf" | null; } -model RealtimeResponseOptions { - ...RealtimeResponseBase; - - /** The modalities for the response. */ - modalities?: RealtimeModalities; - - /** Instructions for the model. */ - instructions?: string; - - @doc(""" - The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. - """) - voice?: RealtimeVoice; - - /** The format of output audio. */ - output_audio_format?: RealtimeAudioFormat; - - // Tool customization: apply enriched tool definition hierarchy - /** Tools (functions) available to the model. */ - tools?: RealtimeTool[]; - - /** How the model chooses tools. */ - tool_choice?: RealtimeToolChoice; - - /** Sampling temperature. */ - temperature?: float32; - - /** Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf". */ - max_output_tokens?: int32 | "inf"; -} - -model RealtimeResponse { - ...RealtimeResponseBase; - object: "realtime.response"; - id: string; - status: RealtimeResponseStatus = RealtimeResponseStatus.in_progress; - status_details: RealtimeResponseStatusDetails | null; - output: RealtimeConversationResponseItem[]; - usage: { - total_tokens: int32; - input_tokens: int32; - output_tokens: int32; - input_token_details: { - cached_tokens: int32; - text_tokens: int32; - audio_tokens: int32; - }; - output_token_details: { - text_tokens: int32; - audio_tokens: int32; - }; - }; -} - union RealtimeVoice { string, alloy: "alloy", - shimmer: "shimmer", + ash: "ash", + ballad: "ballad", + coral: "coral", echo: "echo", + sage: "sage", + shimmer: "shimmer", + verse: "verse", } union RealtimeAudioFormat { @@ -116,7 +74,11 @@ model RealtimeAudioInputTranscriptionSettings { `model`?: RealtimeAudioInputTranscriptionModel = RealtimeAudioInputTranscriptionModel.whisper_1; } -alias RealtimeModalities = ("text" | "audio")[]; +union RealtimeModality { + string, + text: "text", + audio: "audio", +} union RealtimeTurnDetectionType { string, @@ -146,20 +108,6 @@ model RealtimeServerVadTurnDetection extends RealtimeTurnDetection { silence_duration_ms?: duration; // = 200,s } -union RealtimeResponseStatus { - string, - in_progress: "in_progress", - completed: "completed", - cancelled: "cancelled", - incomplete: "incomplete", - failed: "failed", -} - -@discriminator("type") -model RealtimeResponseStatusDetails { - type: RealtimeResponseStatus; -} - model RealtimeServerEventRateLimitsUpdatedRateLimitsItem { /** The rate limit property name that this item includes information about. */ name: string; diff --git a/.typespec/realtime/models.tsp b/.typespec/realtime/models.tsp index 0826558f8..7c7b4a8e4 100644 --- a/.typespec/realtime/models.tsp +++ b/.typespec/realtime/models.tsp @@ -11,11 +11,18 @@ namespace OpenAI; // Tool customization: apply discriminated type base @doc(""" - Send this event to update the session’s default configuration. The client may send this event at any time to update the session configuration, and any field may be updated at any time, except for "voice". The server will respond with a `session.updated` event that shows the full effective configuration. Only fields that are present are updated, thus the correct way to clear a field like "instructions" is to pass an empty string. + Send this event to update the session’s default configuration. The client may + send this event at any time to update the session configuration, and any + field may be updated at any time, except for "voice". The server will respond + with a `session.updated` event that shows the full effective configuration. + Only fields that are present are updated, thus the correct way to clear a + field like "instructions" is to pass an empty string. """) model RealtimeClientEventSessionUpdate extends RealtimeClientEvent { // Tool customization: apply discriminated type base - /** The event type, must be "session.update". */ + @doc(""" + The event type, must be `session.update`. + """) type: RealtimeClientEventType.session_update; // Tool customization: apply enriched request-specific model @@ -24,29 +31,143 @@ model RealtimeClientEventSessionUpdate extends RealtimeClientEvent { // Tool customization: establish custom, enriched discriminated type hierarchy /** The item to add to the conversation. */ +@extension("x-oaiExpandable", true) model RealtimeConversationItemBase { /** Customized to enriched RealtimeConversation{Request,Response}Item models */ } -// Tool customization: apply enriched response type /** The response resource. */ -model RealtimeResponseBase { - /** applied in enriched RealtimeResponse */ +model RealtimeResponse { + /** The unique ID of the response. */ + id?: string; + + @doc(""" + The object type, must be `realtime.response`. + """) + object?: "realtime.response"; + + @doc(""" + The final status of the response (`completed`, `cancelled`, `failed`, or + `incomplete`). + """) + status?: "completed" | "cancelled" | "failed" | "incomplete"; + + /** Additional details about the status. */ + status_details?: { + @doc(""" + The type of error that caused the response to fail, corresponding + with the `status` field (`completed`, `cancelled`, `incomplete`, + `failed`). + """) + type?: "completed" | "cancelled" | "failed" | "incomplete"; + + @doc(""" + The reason the Response did not complete. For a `cancelled` Response, + one of `turn_detected` (the server VAD detected a new start of speech) + or `client_cancelled` (the client sent a cancel event). For an + `incomplete` Response, one of `max_output_tokens` or `content_filter` + (the server-side safety filter activated and cut off the response). + """) + reason?: + | "turn_detected" + | "client_cancelled" + | "max_output_tokens" + | "content_filter"; + + @doc(""" + A description of the error that caused the response to fail, + populated when the `status` is `failed`. + """) + error?: { + /** The type of error. */ + type?: string; + + /** Error code, if any. */ + code?: string; + }; + }; + + // Tool customization: apply enriched response-specific type + /** The list of output items generated by the response. */ + output?: RealtimeConversationResponseItem[]; + + // Tool customization: specialize known metadata string maps + /** Developer-provided string key-value pairs associated with this response. */ + @extension("x-oaiTypeLabel", "map") + metadata?: Record | null; + + /** + * Usage statistics for the Response, this will correspond to billing. A + * Realtime API session will maintain a conversation context and append new + * Items to the Conversation, thus output from previous turns (text and + * audio tokens) will become the input for later turns. + */ + usage?: { + /** + * The total number of tokens in the Response including input and output + * text and audio tokens. + */ + total_tokens?: int32; + + /** + * The number of input tokens used in the Response, including text and + * audio tokens. + */ + input_tokens?: int32; + + /** + * The number of output tokens sent in the Response, including text and + * audio tokens. + */ + output_tokens?: int32; + + /** Details about the input tokens used in the Response. */ + input_token_details?: { + /** The number of cached tokens used in the Response. */ + cached_tokens?: int32; + + /** The number of text tokens used in the Response. */ + text_tokens?: int32; + + /** The number of audio tokens used in the Response. */ + audio_tokens?: int32; + }; + + /** Details about the output tokens used in the Response. */ + output_token_details?: { + /** The number of text tokens used in the Response. */ + text_tokens?: int32; + + /** The number of audio tokens used in the Response. */ + audio_tokens?: int32; + }; + }; } // Tool customization: apply discriminated type base /** - * Send this event to append audio bytes to the input audio buffer. The audio buffer is temporary storage you can write to and later commit. In Server VAD mode, the audio buffer is used to detect speech and the server will decide when to commit. When Server VAD is disabled, you must commit the audio buffer manually. - * The client may choose how much audio to place in each event up to a maximum of 15 MiB, for example streaming smaller chunks from the client may allow the VAD to be more responsive. Unlike made other client events, the server will not send a confirmation response to this event. + * Send this event to append audio bytes to the input audio buffer. The audio + * buffer is temporary storage you can write to and later commit. In Server VAD + * mode, the audio buffer is used to detect speech and the server will decide + * when to commit. When Server VAD is disabled, you must commit the audio buffer + * manually. + * + * The client may choose how much audio to place in each event up to a maximum + * of 15 MiB, for example streaming smaller chunks from the client may allow the + * VAD to be more responsive. Unlike made other client events, the server will + * not send a confirmation response to this event. */ model RealtimeClientEventInputAudioBufferAppend extends RealtimeClientEvent { // Tool customization: apply discriminated type base - /** The event type, must be "input_audio_buffer.append". */ + @doc(""" + The event type, must be `input_audio_buffer.append`. + """) type: RealtimeClientEventType.input_audio_buffer_append; // Tool customization: use encoded type for audio data @doc(""" - Base64-encoded audio bytes. This must be in the format specified by the `input_audio_format` field in the session configuration. + Base64-encoded audio bytes. This must be in the format specified by the + `input_audio_format` field in the session configuration. """) @encode("base64") audio: bytes; @@ -54,29 +175,47 @@ model RealtimeClientEventInputAudioBufferAppend extends RealtimeClientEvent { // Tool customization: apply discriminated type base @doc(""" - Send this event to commit the user input audio buffer, which will create a new user message item in the conversation. This event will produce an error if the input audio buffer is empty. When in Server VAD mode, the client does not need to send this event, the server will commit the audio buffer automatically. - Committing the input audio buffer will trigger input audio transcription (if enabled in session configuration), but it will not create a response from the model. The server will respond with an `input_audio_buffer.committed` event. + Send this event to commit the user input audio buffer, which will create a + new user message item in the conversation. This event will produce an error + if the input audio buffer is empty. When in Server VAD mode, the client does + not need to send this event, the server will commit the audio buffer + automatically. + + Committing the input audio buffer will trigger input audio transcription + (if enabled in session configuration), but it will not create a response + from the model. The server will respond with an `input_audio_buffer.committed` + event. """) model RealtimeClientEventInputAudioBufferCommit extends RealtimeClientEvent { // Tool customization: apply discriminated type base - /** The event type, must be "input_audio_buffer.commit". */ + @doc(""" + The event type, must be `input_audio_buffer.commit`. + """) type: RealtimeClientEventType.input_audio_buffer_commit; } // Tool customization: apply discriminated type base @doc(""" - Send this event to clear the audio bytes in the buffer. The server will respond with an `input_audio_buffer.cleared` event. + Send this event to clear the audio bytes in the buffer. The server will + respond with an `input_audio_buffer.cleared` event. """) model RealtimeClientEventInputAudioBufferClear extends RealtimeClientEvent { // Tool customization: apply discriminated type base - /** The event type, must be "input_audio_buffer.clear". */ + @doc(""" + The event type, must be `input_audio_buffer.clear`. + """) type: RealtimeClientEventType.input_audio_buffer_clear; } // Tool customization: apply discriminated type base @doc(""" - Add a new Item to the Conversation's context, including messages, function calls, and function call responses. This event can be used both to populate a "history" of the conversation and to add new items mid-stream, but has the current limitation that it cannot populate assistant audio messages. - If successful, the server will respond with a `conversation.item.created` event, otherwise an `error` event will be sent. + Add a new Item to the Conversation's context, including messages, function + calls, and function call responses. This event can be used both to populate a + "history" of the conversation and to add new items mid-stream, but has the + current limitation that it cannot populate assistant audio messages. + + If successful, the server will respond with a `conversation.item.created` + event, otherwise an `error` event will be sent. """) model RealtimeClientEventConversationItemCreate extends RealtimeClientEvent { // Tool customization: apply discriminated type base @@ -85,7 +224,12 @@ model RealtimeClientEventConversationItemCreate extends RealtimeClientEvent { """) type: RealtimeClientEventType.conversation_item_create; - /** The ID of the preceding item after which the new item will be inserted. If not set, the new item will be appended to the end of the conversation. If set, it allows an item to be inserted mid-conversation. If the ID cannot be found, an error will be returned and the item will not be added. */ + /** + * The ID of the preceding item after which the new item will be inserted. + * If not set, the new item will be appended to the end of the conversation. + * If set, it allows an item to be inserted mid-conversation. If the ID + * cannot be found, an error will be returned and the item will not be added. + */ previous_item_id?: string; // Tool customization: apply enriched item definition hierarchy @@ -94,32 +238,54 @@ model RealtimeClientEventConversationItemCreate extends RealtimeClientEvent { // Tool customization: apply discriminated type base @doc(""" - Send this event to truncate a previous assistant message’s audio. The server will produce audio faster than realtime, so this event is useful when the user interrupts to truncate audio that has already been sent to the client but not yet played. This will synchronize the server's understanding of the audio with the client's playback. - Truncating audio will delete the server-side text transcript to ensure there is not text in the context that hasn't been heard by the user. - If successful, the server will respond with a `conversation.item.truncated` event. + Send this event to truncate a previous assistant message’s audio. The server + will produce audio faster than realtime, so this event is useful when the user + interrupts to truncate audio that has already been sent to the client but not + yet played. This will synchronize the server's understanding of the audio with + the client's playback. + + Truncating audio will delete the server-side text transcript to ensure there + is not text in the context that hasn't been heard by the user. + + If successful, the server will respond with a `conversation.item.truncated` + event. """) model RealtimeClientEventConversationItemTruncate extends RealtimeClientEvent { // Tool customization: apply discriminated type base - /** The event type, must be "conversation.item.truncate". */ + @doc(""" + The event type, must be `conversation.item.truncate`. + """) type: RealtimeClientEventType.conversation_item_truncate; - /** The ID of the assistant message item to truncate. Only assistant message items can be truncated. */ + /** + * The ID of the assistant message item to truncate. Only assistant message + * items can be truncated. + */ item_id: string; /** The index of the content part to truncate. Set this to 0. */ content_index: int32; - /** Inclusive duration up to which audio is truncated, in milliseconds. If the audio_end_ms is greater than the actual audio duration, the server will respond with an error. */ + /** + * Inclusive duration up to which audio is truncated, in milliseconds. If + * the audio_end_ms is greater than the actual audio duration, the server + * will respond with an error. + */ audio_end_ms: int32; } // Tool customization: apply discriminated type base @doc(""" - Send this event when you want to remove any item from the conversation history. The server will respond with a `conversation.item.deleted` event, unless the item does not exist in the conversation history, in which case the server will respond with an error. + Send this event when you want to remove any item from the conversation + history. The server will respond with a `conversation.item.deleted` event, + unless the item does not exist in the conversation history, in which case the + server will respond with an error. """) model RealtimeClientEventConversationItemDelete extends RealtimeClientEvent { // Tool customization: apply discriminated type base - /** The event type, must be "conversation.item.delete". */ + @doc(""" + The event type, must be `conversation.item.delete`. + """) type: RealtimeClientEventType.conversation_item_delete; /** The ID of the item to delete. */ @@ -128,10 +294,21 @@ model RealtimeClientEventConversationItemDelete extends RealtimeClientEvent { // Tool customization: apply discriminated type base @doc(""" - This event instructs the server to create a Response, which means triggering model inference. When in Server VAD mode, the server will create Responses automatically. - A Response will include at least one Item, and may have two, in which case the second will be a function call. These Items will be appended to the conversation history. - The server will respond with a `response.created` event, events for Items and content created, and finally a `response.done` event to indicate the Response is complete. - The `response.create` event includes inference configuration like `instructions`, and `temperature`. These fields will override the Session's configuration for this Response only. + This event instructs the server to create a Response, which means triggering + model inference. When in Server VAD mode, the server will create Responses + automatically. + + A Response will include at least one Item, and may have two, in which case + the second will be a function call. These Items will be appended to the + conversation history. + + The server will respond with a `response.created` event, events for Items + and content created, and finally a `response.done` event to indicate the + Response is complete. + + The `response.create` event includes inference configuration like + `instructions`, and `temperature`. These fields will override the Session's + configuration for this Response only. """) model RealtimeClientEventResponseCreate extends RealtimeClientEvent { // Tool customization: apply discriminated type base @@ -140,13 +317,14 @@ model RealtimeClientEventResponseCreate extends RealtimeClientEvent { """) type: RealtimeClientEventType.response_create; - // Tool customization: apply custom, distinct type for request-side response options - response: RealtimeResponseOptions; + response?: RealtimeResponseCreateParams; } // Tool customization: apply discriminated type base @doc(""" - Send this event to cancel an in-progress response. The server will respond with a `response.cancelled` event or an error if there is no response to cancel. + Send this event to cancel an in-progress response. The server will respond + with a `response.cancelled` event or an error if there is no response to + cancel. """) model RealtimeClientEventResponseCancel extends RealtimeClientEvent { // Tool customization: apply discriminated type base @@ -154,36 +332,52 @@ model RealtimeClientEventResponseCancel extends RealtimeClientEvent { The event type, must be `response.cancel`. """) type: RealtimeClientEventType.response_cancel; + + /** + * A specific response ID to cancel - if not provided, will cancel an + * in-progress response in the default conversation. + */ + response_id?: string; } // Tool customization: apply discriminated type base -/** Returned when an error occurs, which could be a client problem or a server problem. Most errors are recoverable and the session will stay open, we recommend to implementors to monitor and log error messages by default. */ +/** + * Returned when an error occurs, which could be a client problem or a server + * problem. Most errors are recoverable and the session will stay open, we + * recommend to implementors to monitor and log error messages by default. + */ model RealtimeServerEventError extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "error". */ + @doc(""" + The event type, must be `error`. + """) type: RealtimeServerEventType.error; /** Details of the error. */ error: { /** The type of error (e.g., "invalid_request_error", "server_error"). */ - type?: string; + type: string; /** Error code, if any. */ - code?: string; + code?: string | null; /** A human-readable error message. */ - message?: string; + message: string; /** Parameter related to the error, if any. */ - param?: string; + param?: string | null; /** The event_id of the client event that caused the error, if applicable. */ - event_id?: string; + event_id?: string | null; }; } // Tool customization: apply discriminated type base -/** Returned when a Session is created. Emitted automatically when a new connection is established as the first server event. This event will contain the default Session configuration. */ +/** + * Returned when a Session is created. Emitted automatically when a new + * connection is established as the first server event. This event will contain + * the default Session configuration. + */ model RealtimeServerEventSessionCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type @doc(""" @@ -197,11 +391,14 @@ model RealtimeServerEventSessionCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type base @doc(""" - Returned when a session is updated with a `session.update` event, unless there is an error. + Returned when a session is updated with a `session.update` event, unless + there is an error. """) model RealtimeServerEventSessionUpdated extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "session.updated". */ + @doc(""" + The event type, must be `session.updated`. + """) type: RealtimeServerEventType.session_updated; // Tool customization: apply enriched response-specific model @@ -216,7 +413,9 @@ model RealtimeSessionBase {} /** Returned when a conversation is created. Emitted right after session creation. */ model RealtimeServerEventConversationCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "conversation.created". */ + @doc(""" + The event type, must be `conversation.created`. + """) type: RealtimeServerEventType.conversation_created; /** The conversation resource. */ @@ -224,14 +423,19 @@ model RealtimeServerEventConversationCreated extends RealtimeServerEvent { /** The unique ID of the conversation. */ id?: string; - /** The object type, must be "realtime.conversation". */ + @doc(""" + The object type, must be `realtime.conversation`. + """) object?: string; }; } // Tool customization: apply discriminated type base @doc(""" - Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. The `item_id` property is the ID of the user message item that will be created, thus a `conversation.item.created` event will also be sent to the client. + Returned when an input audio buffer is committed, either by the client or + automatically in server VAD mode. The `item_id` property is the ID of the user + message item that will be created, thus a `conversation.item.created` event + will also be sent to the client. """) model RealtimeServerEventInputAudioBufferCommitted extends RealtimeServerEvent { // Tool customization: apply discriminated type @@ -249,7 +453,8 @@ model RealtimeServerEventInputAudioBufferCommitted extends RealtimeServerEvent { // Tool customization: apply discriminated type base @doc(""" - Returned when the input audio buffer is cleared by the client with a `input_audio_buffer.clear` event. + Returned when the input audio buffer is cleared by the client with a + `input_audio_buffer.clear` event. """) model RealtimeServerEventInputAudioBufferCleared extends RealtimeServerEvent { // Tool customization: apply discriminated type @@ -261,7 +466,16 @@ model RealtimeServerEventInputAudioBufferCleared extends RealtimeServerEvent { // Tool customization: apply discriminated type base @doc(""" - Sent by the server when in `server_vad` mode to indicate that speech has been detected in the audio buffer. This can happen any time audio is added to the buffer (unless speech is already detected). The client may want to use this event to interrupt audio playback or provide visual feedback to the user. The client should expect to receive a `input_audio_buffer.speech_stopped` event when speech stops. The `item_id` property is the ID of the user message item that will be created when speech stops and will also be included in the `input_audio_buffer.speech_stopped` event (unless the client manually commits the audio buffer during VAD activation). + Sent by the server when in `server_vad` mode to indicate that speech has been + detected in the audio buffer. This can happen any time audio is added to the + buffer (unless speech is already detected). The client may want to use this + event to interrupt audio playback or provide visual feedback to the user. + + The client should expect to receive a `input_audio_buffer.speech_stopped` event + when speech stops. The `item_id` property is the ID of the user message item + that will be created when speech stops and will also be included in the + `input_audio_buffer.speech_stopped` event (unless the client manually commits + the audio buffer during VAD activation). """) model RealtimeServerEventInputAudioBufferSpeechStarted extends RealtimeServerEvent { @@ -272,7 +486,10 @@ model RealtimeServerEventInputAudioBufferSpeechStarted type: RealtimeServerEventType.input_audio_buffer_speech_started; @doc(""" - Milliseconds from the start of all audio written to the buffer during the session when speech was first detected. This will correspond to the beginning of audio sent to the model, and thus includes the `prefix_padding_ms` configured in the Session. + Milliseconds from the start of all audio written to the buffer during the + session when speech was first detected. This will correspond to the + beginning of audio sent to the model, and thus includes the + `prefix_padding_ms` configured in the Session. """) audio_start_ms: int32; @@ -282,7 +499,9 @@ model RealtimeServerEventInputAudioBufferSpeechStarted // Tool customization: apply discriminated type base @doc(""" - Returned in `server_vad` mode when the server detects the end of speech in the audio buffer. The server will also send an `conversation.item.created` event with the user message item that is created from the audio buffer. + Returned in `server_vad` mode when the server detects the end of speech in + the audio buffer. The server will also send an `conversation.item.created` + event with the user message item that is created from the audio buffer. """) model RealtimeServerEventInputAudioBufferSpeechStopped extends RealtimeServerEvent { @@ -293,7 +512,9 @@ model RealtimeServerEventInputAudioBufferSpeechStopped type: RealtimeServerEventType.input_audio_buffer_speech_stopped; @doc(""" - Milliseconds since the session started when speech stopped. This will correspond to the end of audio sent to the model, and thus includes the `min_silence_duration_ms` configured in the Session. + Milliseconds since the session started when speech stopped. This will + correspond to the end of audio sent to the model, and thus includes the + `min_silence_duration_ms` configured in the Session. """) audio_end_ms: int32; @@ -303,10 +524,16 @@ model RealtimeServerEventInputAudioBufferSpeechStopped // Tool customization: apply discriminated type base @doc(""" - Returned when a conversation item is created. There are several scenarios that produce this event: - - The server is generating a Response, which if successful will produce either one or two Items, which will be of type `message` (role `assistant`) or type `function_call`. - - The input audio buffer has been committed, either by the client or the server (in `server_vad` mode). The server will take the content of the input audio buffer and add it to a new user message Item. - - The client has sent a `conversation.item.create` event to add a new Item to the Conversation. + Returned when a conversation item is created. There are several scenarios that + produce this event: + - The server is generating a Response, which if successful will produce + either one or two Items, which will be of type `message` + (role `assistant`) or type `function_call`. + - The input audio buffer has been committed, either by the client or the + server (in `server_vad` mode). The server will take the content of the + input audio buffer and add it to a new user message Item. + - The client has sent a `conversation.item.create` event to add a new Item + to the Conversation. """) model RealtimeServerEventConversationItemCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type @@ -315,7 +542,10 @@ model RealtimeServerEventConversationItemCreated extends RealtimeServerEvent { """) type: RealtimeServerEventType.conversation_item_created; - /** The ID of the preceding item in the Conversation context, allows the client to understand the order of the conversation. */ + /** + * The ID of the preceding item in the Conversation context, allows the + * client to understand the order of the conversation. + */ previous_item_id: string; // Tool customization: apply enriched item definition hierarchy @@ -324,14 +554,23 @@ model RealtimeServerEventConversationItemCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type base @doc(""" - This event is the output of audio transcription for user audio written to the user audio buffer. Transcription begins when the input audio buffer is committed by the client or server (in `server_vad` mode). Transcription runs asynchronously with Response creation, so this event may come before or after the Response events. - Realtime API models accept audio natively, and thus input transcription is a separate process run on a separate ASR (Automatic Speech Recognition) model, currently always `whisper-1`. Thus the transcript may diverge somewhat from the model's interpretation, and should be treated as a rough guide. + This event is the output of audio transcription for user audio written to the + user audio buffer. Transcription begins when the input audio buffer is + committed by the client or server (in `server_vad` mode). Transcription runs + asynchronously with Response creation, so this event may come before or after + the Response events. + + Realtime API models accept audio natively, and thus input transcription is a + separate process run on a separate ASR (Automatic Speech Recognition) model, + currently always `whisper-1`. Thus the transcript may diverge somewhat from + the model's interpretation, and should be treated as a rough guide. """) model RealtimeServerEventConversationItemInputAudioTranscriptionCompleted extends RealtimeServerEvent { // Tool customization: apply discriminated type @doc(""" - The event type, must be `conversation.item.input_audio_transcription.completed`. + The event type, must be + `conversation.item.input_audio_transcription.completed`. """) type: RealtimeServerEventType.conversation_item_input_audio_transcription_completed; @@ -347,13 +586,16 @@ model RealtimeServerEventConversationItemInputAudioTranscriptionCompleted // Tool customization: apply discriminated type base @doc(""" - Returned when input audio transcription is configured, and a transcription request for a user message failed. These events are separate from other `error` events so that the client can identify the related Item. + Returned when input audio transcription is configured, and a transcription + request for a user message failed. These events are separate from other + `error` events so that the client can identify the related Item. """) model RealtimeServerEventConversationItemInputAudioTranscriptionFailed extends RealtimeServerEvent { // Tool customization: apply discriminated type @doc(""" - The event type, must be `conversation.item.input_audio_transcription.failed`. + The event type, must be + `conversation.item.input_audio_transcription.failed`. """) type: RealtimeServerEventType.conversation_item_input_audio_transcription_failed; @@ -381,8 +623,12 @@ model RealtimeServerEventConversationItemInputAudioTranscriptionFailed // Tool customization: apply discriminated type base @doc(""" - Returned when an earlier assistant audio message item is truncated by the client with a `conversation.item.truncate` event. This event is used to synchronize the server's understanding of the audio with the client's playback. - This action will truncate the audio and remove the server-side text transcript to ensure there is no text in the context that hasn't been heard by the user. + Returned when an earlier assistant audio message item is truncated by the + client with a `conversation.item.truncate` event. This event is used to + synchronize the server's understanding of the audio with the client's playback. + + This action will truncate the audio and remove the server-side text transcript + to ensure there is no text in the context that hasn't been heard by the user. """) model RealtimeServerEventConversationItemTruncated extends RealtimeServerEvent { // Tool customization: apply discriminated type @@ -403,7 +649,9 @@ model RealtimeServerEventConversationItemTruncated extends RealtimeServerEvent { // Tool customization: apply discriminated type base @doc(""" - Returned when an item in the conversation is deleted by the client with a `conversation.item.delete` event. This event is used to synchronize the server's understanding of the conversation history with the client's view. + Returned when an item in the conversation is deleted by the client with a + `conversation.item.delete` event. This event is used to synchronize the + server's understanding of the conversation history with the client's view. """) model RealtimeServerEventConversationItemDeleted extends RealtimeServerEvent { // Tool customization: apply discriminated type @@ -418,7 +666,8 @@ model RealtimeServerEventConversationItemDeleted extends RealtimeServerEvent { // Tool customization: apply discriminated type base @doc(""" - Returned when a new Response is created. The first event of response creation, where the response is in an initial state of `in_progress`. + Returned when a new Response is created. The first event of response creation, + where the response is in an initial state of `in_progress`. """) model RealtimeServerEventResponseCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type @@ -432,11 +681,15 @@ model RealtimeServerEventResponseCreated extends RealtimeServerEvent { // Tool customization: apply discriminated type base @doc(""" - Returned when a Response is done streaming. Always emitted, no matter the final state. The Response object included in the `response.done` event will include all output Items in the Response but will omit the raw audio data. + Returned when a Response is done streaming. Always emitted, no matter the + final state. The Response object included in the `response.done` event will + include all output Items in the Response but will omit the raw audio data. """) model RealtimeServerEventResponseDone extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.done". */ + @doc(""" + The event type, must be `response.done`. + """) type: RealtimeServerEventType.response_done; response: RealtimeResponse; @@ -462,7 +715,10 @@ model RealtimeServerEventResponseOutputItemAdded extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. */ +/** + * Returned when an Item is done streaming. Also emitted when a Response is + * interrupted, incomplete, or cancelled. + */ model RealtimeServerEventResponseOutputItemDone extends RealtimeServerEvent { // Tool customization: apply discriminated type @doc(""" @@ -481,10 +737,15 @@ model RealtimeServerEventResponseOutputItemDone extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when a new content part is added to an assistant message item during response generation. */ +/** + * Returned when a new content part is added to an assistant message item during + * response generation. + */ model RealtimeServerEventResponseContentPartAdded extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.content_part.added". */ + @doc(""" + The event type, must be `response.content_part.added`. + """) type: RealtimeServerEventType.response_content_part_added; /** The ID of the response. */ @@ -505,10 +766,15 @@ model RealtimeServerEventResponseContentPartAdded extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when a content part is done streaming in an assistant message item. Also emitted when a Response is interrupted, incomplete, or cancelled. */ +/** + * Returned when a content part is done streaming in an assistant message item. + * Also emitted when a Response is interrupted, incomplete, or cancelled. + */ model RealtimeServerEventResponseContentPartDone extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.content_part.done". */ + @doc(""" + The event type, must be `response.content_part.done`. + """) type: RealtimeServerEventType.response_content_part_done; /** The ID of the response. */ @@ -532,7 +798,9 @@ model RealtimeServerEventResponseContentPartDone extends RealtimeServerEvent { /** Returned when the text value of a "text" content part is updated. */ model RealtimeServerEventResponseTextDelta extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.text.delta". */ + @doc(""" + The event type, must be `response.text.delta`. + """) type: RealtimeServerEventType.response_text_delta; /** The ID of the response. */ @@ -552,10 +820,15 @@ model RealtimeServerEventResponseTextDelta extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when the text value of a "text" content part is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. */ +/** + * Returned when the text value of a "text" content part is done streaming. Also + * emitted when a Response is interrupted, incomplete, or cancelled. + */ model RealtimeServerEventResponseTextDone extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.text.done". */ + @doc(""" + The event type, must be `response.text.done`. + """) type: RealtimeServerEventType.response_text_done; /** The ID of the response. */ @@ -579,7 +852,9 @@ model RealtimeServerEventResponseTextDone extends RealtimeServerEvent { model RealtimeServerEventResponseAudioTranscriptDelta extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.audio_transcript.delta". */ + @doc(""" + The event type, must be `response.audio_transcript.delta`. + """) type: RealtimeServerEventType.response_audio_transcript_delta; /** The ID of the response. */ @@ -599,11 +874,17 @@ model RealtimeServerEventResponseAudioTranscriptDelta } // Tool customization: apply discriminated type base -/** Returned when the model-generated transcription of audio output is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. */ +/** + * Returned when the model-generated transcription of audio output is done + * streaming. Also emitted when a Response is interrupted, incomplete, or + * cancelled. + */ model RealtimeServerEventResponseAudioTranscriptDone extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.audio_transcript.done". */ + @doc(""" + The event type, must be `response.audio_transcript.done`. + """) type: RealtimeServerEventType.response_audio_transcript_done; /** The ID of the response. */ @@ -626,7 +907,9 @@ model RealtimeServerEventResponseAudioTranscriptDone /** Returned when the model-generated audio is updated. */ model RealtimeServerEventResponseAudioDelta extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.audio.delta". */ + @doc(""" + The event type, must be `response.audio.delta`. + """) type: RealtimeServerEventType.response_audio_delta; /** The ID of the response. */ @@ -648,10 +931,15 @@ model RealtimeServerEventResponseAudioDelta extends RealtimeServerEvent { } // Tool customization: apply discriminated type base -/** Returned when the model-generated audio is done. Also emitted when a Response is interrupted, incomplete, or cancelled. */ +/** + * Returned when the model-generated audio is done. Also emitted when a Response + * is interrupted, incomplete, or cancelled. + */ model RealtimeServerEventResponseAudioDone extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.audio.done". */ + @doc(""" + The event type, must be `response.audio.done`. + """) type: RealtimeServerEventType.response_audio_done; /** The ID of the response. */ @@ -672,7 +960,9 @@ model RealtimeServerEventResponseAudioDone extends RealtimeServerEvent { model RealtimeServerEventResponseFunctionCallArgumentsDelta extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.function_call_arguments.delta". */ + @doc(""" + The event type, must be `response.function_call_arguments.delta`. + """) type: RealtimeServerEventType.response_function_call_arguments_delta; /** The ID of the response. */ @@ -692,11 +982,16 @@ model RealtimeServerEventResponseFunctionCallArgumentsDelta } // Tool customization: apply discriminated type base -/** Returned when the model-generated function call arguments are done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. */ +/** + * Returned when the model-generated function call arguments are done streaming. + * Also emitted when a Response is interrupted, incomplete, or cancelled. + */ model RealtimeServerEventResponseFunctionCallArgumentsDone extends RealtimeServerEvent { // Tool customization: apply discriminated type - /** The event type, must be "response.function_call_arguments.done". */ + @doc(""" + The event type, must be `response.function_call_arguments.done`. + """) type: RealtimeServerEventType.response_function_call_arguments_done; /** The ID of the response. */ @@ -716,7 +1011,12 @@ model RealtimeServerEventResponseFunctionCallArgumentsDone } // Tool customization: apply discriminated type base -/** Emitted at the beginning of a Response to indicate the updated rate limits. When a Response is created some tokens will be "reserved" for the output tokens, the rate limits shown here reflect that reservation, which is then adjusted accordingly once the Response is completed. */ +/** + * Emitted at the beginning of a Response to indicate the updated rate limits. + * When a Response is created some tokens will be "reserved" for the output + * tokens, the rate limits shown here reflect that reservation, which is then + * adjusted accordingly once the Response is completed. + */ model RealtimeServerEventRateLimitsUpdated extends RealtimeServerEvent { // Tool customization: apply discriminated type @doc(""" @@ -728,3 +1028,357 @@ model RealtimeServerEventRateLimitsUpdated extends RealtimeServerEvent { /** List of rate limit information. */ rate_limits: RealtimeServerEventRateLimitsUpdatedRateLimitsItem[]; } + +/** Create a new Realtime response with these parameters */ +model RealtimeResponseCreateParams { + // Tool customization: Apply reusable modality representation + /** + * The set of modalities the model can respond with. To disable audio, + * set this to ["text"]. + */ + modalities?: RealtimeModality[]; + + @doc(""" + The default system instructions (i.e. system message) prepended to model + calls. This field allows the client to guide the model on desired + responses. The model can be instructed on response content and format, + (e.g. "be extremely succinct", "act friendly", "here are examples of good + responses") and on audio behavior (e.g. "talk quickly", "inject emotion + into your voice", "laugh frequently"). The instructions are not guaranteed + to be followed by the model, but they provide guidance to the model on the + desired behavior. + + Note that the server sets default instructions which will be used if this + field is not set and are visible in the `session.created` event at the + start of the session. + """) + instructions?: string; + + // Tool customization: use extracted and reusable voice definition + @doc(""" + The voice the model uses to respond. Voice cannot be changed during the + session once the model has responded with audio at least once. Current + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + `shimmer` and `verse`. + """) + voice?: RealtimeVoice; + + // Tool customization: use extracted and reusable audio format definition + @doc(""" + The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + """) + output_audio_format?: RealtimeAudioFormat; + + // Tool customization: use enriched tool definition + /** Tools (functions) available to the model. */ + tools?: RealtimeTool[]; + + @doc(""" + How the model chooses tools. Options are `auto`, `none`, `required`, or + specify a function, like `{"type": "function", "function": {"name": "my_function"}}`. + """) + tool_choice?: string; + + /** Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. */ + temperature?: float32; + + @doc(""" + Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. + """) + max_response_output_tokens?: int32 | "inf"; + + @doc(""" + Controls which conversation the response is added to. Currently supports + `auto` and `none`, with `auto` as the default value. The `auto` value + means that the contents of the response will be added to the default + conversation. Set this to `none` to create an out-of-band response which + will not add items to default conversation. + """) + conversation?: string | "auto" | "none"; + + // Tool customization: specialize known metadata string maps + /** + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. + */ + @extension("x-oaiTypeLabel", "map") + metadata?: Record | null; + + // Tool customization: apply a customized, specific item type + /** + * Input items to include in the prompt for the model. Creates a new context + * for this response, without including the default conversation. Can include + * references to items from the default conversation. + */ + input?: RealtimeConversationRequestItem[]; +} + +/** Realtime session object configuration. */ +model RealtimeSessionCreateRequest { + // Tool customization: Apply reusable modality representation + /** + * The set of modalities the model can respond with. To disable audio, + * set this to ["text"]. + */ + modalities?: RealtimeModality[]; + + /** The Realtime model used for this session. */ + `model`: + | "gpt-4o-realtime-preview" + | "gpt-4o-realtime-preview-2024-10-01" + | "gpt-4o-realtime-preview-2024-12-17" + | "gpt-4o-mini-realtime-preview" + | "gpt-4o-mini-realtime-preview-2024-12-17"; + + @doc(""" + The default system instructions (i.e. system message) prepended to model + calls. This field allows the client to guide the model on desired + responses. The model can be instructed on response content and format, + (e.g. "be extremely succinct", "act friendly", "here are examples of good + responses") and on audio behavior (e.g. "talk quickly", "inject emotion + into your voice", "laugh frequently"). The instructions are not guaranteed + to be followed by the model, but they provide guidance to the model on the + desired behavior. + + Note that the server sets default instructions which will be used if this + field is not set and are visible in the `session.created` event at the + start of the session. + """) + instructions?: string; + + // Tool customization: use extracted and reusable voice definition + @doc(""" + The voice the model uses to respond. Voice cannot be changed during the + session once the model has responded with audio at least once. Current + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + `shimmer` and `verse`. + """) + voice?: RealtimeVoice; + + // Tool customization: use extracted and reusable audio format definition + @doc(""" + The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + """) + input_audio_format?: RealtimeAudioFormat; + + // Tool customization: use extracted and reusable audio format definition + @doc(""" + The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + """) + output_audio_format?: RealtimeAudioFormat; + + @doc(""" + Configuration for input audio transcription, defaults to off and can be + set to `null` to turn off once on. Input audio transcription is not native + to the model, since the model consumes audio directly. Transcription runs + asynchronously through Whisper and should be treated as rough guidance + rather than the representation understood by the model. + """) + input_audio_transcription?: { + @doc(""" + The model to use for transcription, `whisper-1` is the only currently + supported model. + """) + `model`?: string; + }; + + @doc(""" + Configuration for turn detection. Can be set to `null` to turn off. Server + VAD means that the model will detect the start and end of speech based on + audio volume and respond at the end of user speech. + """) + turn_detection?: { + @doc(""" + Type of turn detection, only `server_vad` is currently supported. + """) + type?: string; + + /** + * Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A + * higher threshold will require louder audio to activate the model, and + * thus might perform better in noisy environments. + */ + threshold?: float32; + + /** + * Amount of audio to include before the VAD detected speech (in + * milliseconds). Defaults to 300ms. + */ + prefix_padding_ms?: int32; + + /** + * Duration of silence to detect speech stop (in milliseconds). Defaults + * to 500ms. With shorter values the model will respond more quickly, + * but may jump in on short pauses from the user. + */ + silence_duration_ms?: int32; + + @doc(""" + Whether or not to automatically generate a response when VAD is + enabled. `true` by default. + """) + create_response?: boolean = true; + }; + + // Tool customization: use enriched tool definition + /** Tools (functions) available to the model. */ + tools?: RealtimeTool[]; + + @doc(""" + How the model chooses tools. Options are `auto`, `none`, `required`, or + specify a function. + """) + tool_choice?: string; + + /** Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. */ + temperature?: float32; + + @doc(""" + Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. + """) + max_response_output_tokens?: int32 | "inf"; +} + +/** + * A new Realtime session configuration, with an ephermeral key. Default TTL + * for keys is one minute. + */ +model RealtimeSessionCreateResponse { + /** Ephemeral key returned by the API. */ + client_secret?: { + /** + * Ephemeral key usable in client environments to authenticate connections + * to the Realtime API. Use this in client-side environments rather than + * a standard API token, which should only be used server-side. + */ + value?: string; + + // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime + /** + * Timestamp for when the token expires. Currently, all tokens expire + * after one minute. + */ + @encode("unixTimestamp", int32) + expires_at?: utcDateTime; + }; + + // Tool customization: Apply reusable modality representation + /** + * The set of modalities the model can respond with. To disable audio, + * set this to ["text"]. + */ + modalities?: RealtimeModality[]; + + @doc(""" + The default system instructions (i.e. system message) prepended to model + calls. This field allows the client to guide the model on desired + responses. The model can be instructed on response content and format, + (e.g. "be extremely succinct", "act friendly", "here are examples of good + responses") and on audio behavior (e.g. "talk quickly", "inject emotion + into your voice", "laugh frequently"). The instructions are not guaranteed + to be followed by the model, but they provide guidance to the model on the + desired behavior. + + Note that the server sets default instructions which will be used if this + field is not set and are visible in the `session.created` event at the + start of the session. + """) + instructions?: string; + + // Tool customization: use extracted and reusable voice definition + @doc(""" + The voice the model uses to respond. Voice cannot be changed during the + session once the model has responded with audio at least once. Current + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + `shimmer` and `verse`. + """) + voice?: RealtimeVoice; + + // Tool customization: use extracted and reusable audio format definition + @doc(""" + The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + """) + input_audio_format?: RealtimeAudioFormat; + + // Tool customization: use extracted and reusable audio format definition + @doc(""" + The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + """) + output_audio_format?: RealtimeAudioFormat; + + @doc(""" + Configuration for input audio transcription, defaults to off and can be + set to `null` to turn off once on. Input audio transcription is not native + to the model, since the model consumes audio directly. Transcription runs + asynchronously through Whisper and should be treated as rough guidance + rather than the representation understood by the model. + """) + input_audio_transcription?: { + @doc(""" + The model to use for transcription, `whisper-1` is the only currently + supported model. + """) + `model`?: string; + }; + + @doc(""" + Configuration for turn detection. Can be set to `null` to turn off. Server + VAD means that the model will detect the start and end of speech based on + audio volume and respond at the end of user speech. + """) + turn_detection?: { + @doc(""" + Type of turn detection, only `server_vad` is currently supported. + """) + type?: string; + + /** + * Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A + * higher threshold will require louder audio to activate the model, and + * thus might perform better in noisy environments. + */ + threshold?: float32; + + /** + * Amount of audio to include before the VAD detected speech (in + * milliseconds). Defaults to 300ms. + */ + prefix_padding_ms?: int32; + + /** + * Duration of silence to detect speech stop (in milliseconds). Defaults + * to 500ms. With shorter values the model will respond more quickly, + * but may jump in on short pauses from the user. + */ + silence_duration_ms?: int32; + }; + + // Tool customization: use enriched tool definition + /** Tools (functions) available to the model. */ + tools?: RealtimeTool[]; + + @doc(""" + How the model chooses tools. Options are `auto`, `none`, `required`, or + specify a function. + """) + tool_choice?: string; + + /** Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. */ + temperature?: float32; + + @doc(""" + Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. + """) + max_response_output_tokens?: int32 | "inf"; +} diff --git a/.typespec/runs/models.tsp b/.typespec/runs/models.tsp index f257be17c..c19fa6f67 100644 --- a/.typespec/runs/models.tsp +++ b/.typespec/runs/models.tsp @@ -34,6 +34,7 @@ model CreateRunRequest { `model`?: | string | "gpt-4o" + | "gpt-4o-2024-11-20" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-mini" @@ -132,6 +133,7 @@ model CreateThreadAndRunRequest { `model`?: | string | "gpt-4o" + | "gpt-4o-2024-11-20" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-mini" @@ -293,10 +295,13 @@ model RunStepDetailsToolCallsObject extends RunStepObjectStepDetails { /** Details of the Code Interpreter tool call the run step was involved in. */ model RunStepDetailsToolCallsCodeObject extends RunStepDetailsToolCallsObjectToolCallsObject { + /** The ID of the tool call. */ + id: string; + @doc(""" The type of tool call. This is always going to be `code_interpreter` for this type of tool call. """) - type: RunStepDetailsToolCallKind.code_interpreter; + type: "code_interpreter"; /** The Code Interpreter tool call definition. */ code_interpreter: { @@ -343,10 +348,13 @@ model RunStepDetailsToolCallsCodeOutputImageObject // Tool customization: apply custom, common base type to union items model RunStepDetailsToolCallsFileSearchObject extends RunStepDetailsToolCallsObjectToolCallsObject { + /** The ID of the tool call object. */ + id: string; + @doc(""" The type of tool call. This is always going to be `file_search` for this type of tool call. """) - type: RunStepDetailsToolCallKind.file_search; + type: "file_search"; /** For now, this is always going to be an empty object. */ @extension("x-oaiTypeLabel", "map") @@ -388,7 +396,7 @@ model RunStepDetailsToolCallsFileSearchResultObject { /** The content of the result that was found. The content is only included if requested via the include query parameter. */ content?: { /** The type of the content. */ - type: "text"; + type?: "text"; /** The text content of the file. */ text?: string; @@ -398,10 +406,13 @@ model RunStepDetailsToolCallsFileSearchResultObject { // Tool customization: apply custom, common base type to union items model RunStepDetailsToolCallsFunctionObject extends RunStepDetailsToolCallsObjectToolCallsObject { + /** The ID of the tool call object. */ + id: string; + @doc(""" The type of tool call. This is always going to be `function` for this type of tool call. """) - type: RunStepDetailsToolCallKind.function; + type: "function"; /** The definition of the function that was called. */ function: { @@ -813,13 +824,7 @@ model RunStepDeltaStepDetailsToolCallsFileSearchObject /** For now, this is always going to be an empty object. */ @extension("x-oaiTypeLabel", "map") - file_search: { - ranking_options?: RunStepDetailsToolCallsFileSearchRankingOptionsObject; - - /** The results of the file search. */ - @visibility("read") - results?: RunStepDetailsToolCallsFileSearchResultObject[]; - }; + file_search: Record; } // Tool customization: apply custom, common base type to union items diff --git a/.typespec/streaming/models.tsp b/.typespec/streaming/models.tsp index a19baf0bf..828787e66 100644 --- a/.typespec/streaming/models.tsp +++ b/.typespec/streaming/models.tsp @@ -149,7 +149,7 @@ union MessageStreamEvent { }, } -/** Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This can happen due to an internal server error or a timeout. */ +/** Occurs when an [error](/docs/guides/error-codes#api-errors) occurs. This can happen due to an internal server error or a timeout. */ model ErrorEvent { event: "error"; data: Error; diff --git a/.typespec/uploads/models.tsp b/.typespec/uploads/models.tsp index 13fe13989..1754186de 100644 --- a/.typespec/uploads/models.tsp +++ b/.typespec/uploads/models.tsp @@ -9,6 +9,30 @@ using TypeSpec.OpenAPI; namespace OpenAI; +model AdminApiKey { + object?: string; + id?: string; + name?: string; + redacted_value?: string; + value?: string; + + // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime + @encode("unixTimestamp", int32) + created_at?: utcDateTime; + + owner?: { + type?: string; + id?: string; + name?: string; + + // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime + @encode("unixTimestamp", int32) + created_at?: utcDateTime; + + role?: string; + }; +} + model CreateUploadRequest { /** The name of the file to upload. */ filename: string; diff --git a/README.md b/README.md index ed5c9897a..c105bcdca 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,19 @@ For information on spec ingestion, see the Sorento wiki page: https://dev.azure.com/project-argos/Sorento/_wiki/wikis/Sorento.wiki/3021/Generate-OpenAI's-YAML-Spec -Snapshot: https://project-argos@dev.azure.com/project-argos/Sorento/_git/export-api@54593e37 -Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk@da3aa64 +Snapshot: https://project-argos@dev.azure.com/project-argos/Sorento/_git/export-api +``` +commit 2b12183ef3a0ddd81b3b4f51c201479183b34788 (HEAD -> main, origin/main) +Author: Git-Mirror-Tool Synchronizer +Date: Mon Jan 6 22:44:48 2025 +0000 +``` + +Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk +``` +commit c41442a13bf38ac4f30840bee648488991661e17 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) +Author: Travis Wilson +Date: Thu Jan 9 14:24:11 2025 -0800 +``` There are some deltas: diff --git a/openapi3-original.yaml b/openapi3-original.yaml index 684a653b5..06c41dc39 100644 --- a/openapi3-original.yaml +++ b/openapi3-original.yaml @@ -88,7 +88,7 @@ paths: description: > A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list - request and receive 100 objects, ending with obj_foo, your + request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. schema: @@ -965,7 +965,7 @@ paths: Your input file must be formatted as a [JSONL file](/docs/api-reference/batch/request-input), and must be uploaded with the purpose `batch`. The file can contain up - to 50,000 requests, and can be up to 100 MB in size. + to 50,000 requests, and can be up to 200 MB in size. endpoint: type: string enum: @@ -1338,6 +1338,19 @@ paths: [vision](/docs/guides/vision), and [audio](/docs/guides/audio) guides. + + + Parameter support can differ depending on the model used to generate the + + response, particularly for newer reasoning models. Parameters that are + only + + supported for reasoning models are noted below. For the current state + of + + unsupported parameters in reasoning models, + + [refer to the reasoning guide](/docs/guides/reasoning). requestBody: required: true content: @@ -1368,10 +1381,10 @@ paths: -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ - "model": "VAR_model_id", + "model": "VAR_chat_model_id", "messages": [ { - "role": "system", + "role": "developer", "content": "You are a helpful assistant." }, { @@ -1387,9 +1400,9 @@ paths: completion = client.chat.completions.create( - model="VAR_model_id", + model="VAR_chat_model_id", messages=[ - {"role": "system", "content": "You are a helpful assistant."}, + {"role": "developer", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ] ) @@ -1405,8 +1418,8 @@ paths: async function main() { const completion = await openai.chat.completions.create({ - messages: [{ role: "system", content: "You are a helpful assistant." }], - model: "VAR_model_id", + messages: [{ role: "developer", content: "You are a helpful assistant." }], + model: "VAR_chat_model_id", }); console.log(completion.choices[0]); @@ -1435,7 +1448,9 @@ paths: "completion_tokens": 12, "total_tokens": 21, "completion_tokens_details": { - "reasoning_tokens": 0 + "reasoning_tokens": 0, + "accepted_prediction_tokens": 0, + "rejected_prediction_tokens": 0 } } } @@ -1544,7 +1559,9 @@ paths: "completion_tokens": 12, "total_tokens": 21, "completion_tokens_details": { - "reasoning_tokens": 0 + "reasoning_tokens": 0, + "accepted_prediction_tokens": 0, + "rejected_prediction_tokens": 0 } } } @@ -1555,10 +1572,10 @@ paths: -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ - "model": "VAR_model_id", + "model": "VAR_chat_model_id", "messages": [ { - "role": "system", + "role": "developer", "content": "You are a helpful assistant." }, { @@ -1575,9 +1592,9 @@ paths: completion = client.chat.completions.create( - model="VAR_model_id", + model="VAR_chat_model_id", messages=[ - {"role": "system", "content": "You are a helpful assistant."}, + {"role": "developer", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], stream=True @@ -1595,9 +1612,9 @@ paths: async function main() { const completion = await openai.chat.completions.create({ - model: "VAR_model_id", + model: "VAR_chat_model_id", messages: [ - {"role": "system", "content": "You are a helpful assistant."}, + {"role": "developer", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], stream: true, @@ -1700,7 +1717,7 @@ paths: in Boston today?"}] completion = client.chat.completions.create( - model="VAR_model_id", + model="VAR_chat_model_id", messages=messages, tools=tools, tool_choice="auto" @@ -1782,7 +1799,9 @@ paths: "completion_tokens": 17, "total_tokens": 99, "completion_tokens_details": { - "reasoning_tokens": 0 + "reasoning_tokens": 0, + "accepted_prediction_tokens": 0, + "rejected_prediction_tokens": 0 } } } @@ -1793,7 +1812,7 @@ paths: -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ - "model": "VAR_model_id", + "model": "VAR_chat_model_id", "messages": [ { "role": "user", @@ -1808,7 +1827,7 @@ paths: client = OpenAI() completion = client.chat.completions.create( - model="VAR_model_id", + model="VAR_chat_model_id", messages=[ {"role": "user", "content": "Hello!"} ], @@ -1826,7 +1845,7 @@ paths: async function main() { const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: "Hello!" }], - model: "VAR_model_id", + model: "VAR_chat_model_id", logprobs: true, top_logprobs: 2, }); @@ -2018,7 +2037,9 @@ paths: "completion_tokens": 9, "total_tokens": 18, "completion_tokens_details": { - "reasoning_tokens": 0 + "reasoning_tokens": 0, + "accepted_prediction_tokens": 0, + "rejected_prediction_tokens": 0 } }, "system_fingerprint": null @@ -2057,7 +2078,7 @@ paths: -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ - "model": "VAR_model_id", + "model": "VAR_completion_model_id", "prompt": "Say this is a test", "max_tokens": 7, "temperature": 0 @@ -2067,7 +2088,7 @@ paths: client = OpenAI() client.completions.create( - model="VAR_model_id", + model="VAR_completion_model_id", prompt="Say this is a test", max_tokens=7, temperature=0 @@ -2079,7 +2100,7 @@ paths: async function main() { const completion = await openai.completions.create({ - model: "VAR_model_id", + model: "VAR_completion_model_id", prompt: "Say this is a test.", max_tokens: 7, temperature: 0, @@ -2093,7 +2114,7 @@ paths: "id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7", "object": "text_completion", "created": 1589478378, - "model": "VAR_model_id", + "model": "VAR_completion_model_id", "system_fingerprint": "fp_44709d6fcb", "choices": [ { @@ -2116,7 +2137,7 @@ paths: -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ - "model": "VAR_model_id", + "model": "VAR_completion_model_id", "prompt": "Say this is a test", "max_tokens": 7, "temperature": 0, @@ -2127,7 +2148,7 @@ paths: client = OpenAI() for chunk in client.completions.create( - model="VAR_model_id", + model="VAR_completion_model_id", prompt="Say this is a test", max_tokens=7, temperature=0, @@ -2141,7 +2162,7 @@ paths: async function main() { const stream = await openai.completions.create({ - model: "VAR_model_id", + model: "VAR_completion_model_id", prompt: "Say this is a test.", stream: true, }); @@ -2252,7 +2273,7 @@ paths: operationId: listFiles tags: - Files - summary: Returns a list of files that belong to the user's organization. + summary: Returns a list of files. parameters: - in: query name: purpose @@ -2260,6 +2281,35 @@ paths: schema: type: string description: Only return files with the given purpose. + - name: limit + in: query + description: > + A limit on the number of objects to be returned. Limit can range + between 1 and 10,000, and the default is 10,000. + required: false + schema: + type: integer + default: 10000 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + - name: after + in: query + description: > + A cursor for use in pagination. `after` is an object ID that defines + your place in the list. For instance, if you make a list request and + receive 100 objects, ending with obj_foo, your subsequent call can + include after=obj_foo in order to fetch the next page of the list. + schema: + type: string responses: "200": description: OK @@ -2338,7 +2388,7 @@ paths: [completions](/docs/api-reference/fine-tuning/completions-input) models. - The Batch API only supports `.jsonl` files up to 100 MB in size. The + The Batch API only supports `.jsonl` files up to 200 MB in size. The input also has a specific required [format](/docs/api-reference/batch/request-input). @@ -2633,6 +2683,16 @@ paths: "status": "queued", "validation_file": null, "training_file": "file-abc123", + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": "auto", + } + } + } } - title: Epochs request: @@ -2643,8 +2703,13 @@ paths: -d '{ "training_file": "file-abc123", "model": "gpt-4o-mini", - "hyperparameters": { - "n_epochs": 2 + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "n_epochs": 2 + } + } } }' python: | @@ -2654,8 +2719,13 @@ paths: client.fine_tuning.jobs.create( training_file="file-abc123", model="gpt-4o-mini", - hyperparameters={ - "n_epochs":2 + method={ + "type": "supervised", + "supervised": { + "hyperparameters": { + "n_epochs": 2 + } + } } ) node.js: | @@ -2667,7 +2737,14 @@ paths: const fineTune = await openai.fineTuning.jobs.create({ training_file: "file-abc123", model: "gpt-4o-mini", - hyperparameters: { n_epochs: 2 } + method: { + type: "supervised", + supervised: { + hyperparameters: { + n_epochs: 2 + } + } + } }); console.log(fineTune); @@ -2687,6 +2764,16 @@ paths: "validation_file": null, "training_file": "file-abc123", "hyperparameters": {"n_epochs": 2}, + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": 2, + } + } + } } - title: Validation file request: @@ -2735,6 +2822,59 @@ paths: "status": "queued", "validation_file": "file-abc123", "training_file": "file-abc123", + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": "auto", + } + } + } + } + - title: DPO + request: + curl: | + curl https://api.openai.com/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "training_file": "file-abc123", + "validation_file": "file-abc123", + "model": "gpt-4o-mini", + "method": { + "type": "dpo", + "dpo": { + "hyperparameters": { + "beta": 0.1, + } + } + } + }' + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-4o-mini-2024-07-18", + "created_at": 1721764800, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "queued", + "validation_file": "file-abc123", + "training_file": "file-abc123", + "method": { + "type": "dpo", + "dpo": { + "hyperparameters": { + "beta": 0.1, + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": "auto", + } + } + } } - title: W&B Integration request: @@ -2780,7 +2920,17 @@ paths: "run_id": "ftjob-abc123" } } - ] + ], + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": "auto", + } + } + } } get: operationId: listPaginatedFineTuningJobs @@ -2935,7 +3085,17 @@ paths: "trained_tokens": 5768, "integrations": [], "seed": 0, - "estimated_finish": 0 + "estimated_finish": 0, + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "n_epochs": 4, + "batch_size": 1, + "learning_rate_multiplier": 1.0 + } + } + } } /fine_tuning/jobs/{fine_tuning_job_id}/cancel: post: @@ -2999,9 +3159,6 @@ paths: "fine_tuned_model": null, "organization_id": "org-123", "result_files": [], - "hyperparameters": { - "n_epochs": "auto" - }, "status": "cancelled", "validation_file": "file-abc123", "training_file": "file-abc123" @@ -3490,20 +3647,20 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/models/VAR_model_id \ + curl https://api.openai.com/v1/models/VAR_chat_model_id \ -H "Authorization: Bearer $OPENAI_API_KEY" python: | from openai import OpenAI client = OpenAI() - client.models.retrieve("VAR_model_id") + client.models.retrieve("VAR_chat_model_id") node.js: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const model = await openai.models.retrieve("VAR_model_id"); + const model = await openai.models.retrieve("VAR_chat_model_id"); console.log(model); } @@ -3511,7 +3668,7 @@ paths: main(); response: | { - "id": "VAR_model_id", + "id": "VAR_chat_model_id", "object": "model", "created": 1686935002, "owned_by": "openai" @@ -3821,6 +3978,245 @@ paths: } ] } + /organization/admin_api_keys: + get: + summary: List organization API keys + operationId: admin-api-keys-list + description: Retrieve a paginated list of organization admin API keys. + parameters: + - in: query + name: after + required: false + schema: + type: string + nullable: true + description: Return keys with IDs that come after this ID in the pagination + order. + - in: query + name: order + required: false + schema: + type: string + enum: + - asc + - desc + default: asc + description: Order results by creation time, ascending or descending. + - in: query + name: limit + required: false + schema: + type: integer + default: 20 + description: Maximum number of keys to return. + responses: + "200": + description: A list of organization API keys. + content: + application/json: + schema: + $ref: "#/components/schemas/ApiKeyList" + security: + - bearer_identity_edge: + - key.secret + - api.management.read + - basic_identity_edge: [] + x-oaiMeta: + name: List admin API keys + group: administration + returns: A list of admin API key objects. + examples: + request: + curl: > + curl + https://api.openai.com/v1/organization/admin_api_keys?after=key_abc&limit=20 + \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + response: | + { + "object": "list", + "data": [ + { + "object": "organization.admin_api_key", + "id": "key_abc", + "name": "Main Admin Key", + "redacted_value": "sk-admin...def", + "created_at": 1711471533, + "owner": { + "type": "service_account", + "object": "organization.service_account", + "id": "sa_456", + "name": "My Service Account", + "created_at": 1711471533, + "role": "member" + } + } + ], + "first_id": "key_abc", + "last_id": "key_abc", + "has_more": false + } + post: + summary: Create an organization admin API key + operationId: admin-api-keys-create + description: Create a new admin-level API key for the organization. + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - name + properties: + name: + type: string + example: New Admin Key + responses: + "200": + description: The newly created admin API key. + content: + application/json: + schema: + $ref: "#/components/schemas/AdminApiKey" + security: + - bearer_identity_edge: + - key.secret + - api.management.write + - basic_identity_edge: [] + x-oaiMeta: + name: Create admin API key + group: administration + returns: The created admin API key object. + examples: + request: + curl: > + curl -X POST https://api.openai.com/v1/organization/admin_api_keys + \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "New Admin Key" + }' + response: | + { + "object": "organization.admin_api_key", + "id": "key_xyz", + "name": "New Admin Key", + "redacted_value": "sk-admin...xyz", + "created_at": 1711471533, + "owner": { + "type": "user", + "object": "organization.user", + "id": "user_123", + "name": "John Doe", + "created_at": 1711471533, + "role": "owner" + }, + "value": "sk-admin-1234abcd" + } + /organization/admin_api_keys/{key_id}: + get: + summary: Retrieve a single organization API key + operationId: admin-api-keys-get + description: Get details for a specific organization API key by its ID. + parameters: + - in: path + name: key_id + required: true + schema: + type: string + description: The ID of the API key. + responses: + "200": + description: Details of the requested API key. + content: + application/json: + schema: + $ref: "#/components/schemas/AdminApiKey" + security: + - bearer_identity_edge: + - key.secret + - api.management.read + - basic_identity_edge: [] + x-oaiMeta: + name: Retrieve admin API key + group: administration + returns: The requested admin API key object. + examples: + request: + curl: > + curl https://api.openai.com/v1/organization/admin_api_keys/key_abc + \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + response: | + { + "object": "organization.admin_api_key", + "id": "key_abc", + "name": "Main Admin Key", + "redacted_value": "sk-admin...xyz", + "created_at": 1711471533, + "owner": { + "type": "user", + "object": "organization.user", + "id": "user_123", + "name": "John Doe", + "created_at": 1711471533, + "role": "owner" + } + } + delete: + summary: Delete an organization admin API key + operationId: admin-api-keys-delete + description: Delete the specified admin API key. + parameters: + - in: path + name: key_id + required: true + schema: + type: string + description: The ID of the API key to be deleted. + responses: + "200": + description: Confirmation that the API key was deleted. + content: + application/json: + schema: + type: object + properties: + id: + type: string + example: key_abc + object: + type: string + example: organization.admin_api_key.deleted + deleted: + type: boolean + example: true + security: + - bearer_identity_edge: + - key.secret + - api.management.write + - basic_identity_edge: [] + x-oaiMeta: + name: Delete admin API key + group: administration + returns: A confirmation object indicating the key was deleted. + examples: + request: + curl: > + curl -X DELETE + https://api.openai.com/v1/organization/admin_api_keys/key_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + response: | + { + "id": "key_abc", + "object": "organization.admin_api_key.deleted", + "deleted": true + } /organization/audit_logs: get: summary: List user actions and configuration changes within this organization. @@ -3919,7 +4315,7 @@ paths: description: > A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list - request and receive 100 objects, ending with obj_foo, your + request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. schema: @@ -3941,7 +4337,7 @@ paths: curl: | curl https://api.openai.com/v1/organization/audit_logs \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ + -H "Content-Type: application/json" response: > { "object": "list", @@ -3976,7 +4372,18 @@ paths: "email": "user@example.com" }, "ip_address": "127.0.0.1", - "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" + "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36", + "ja3": "a497151ce4338a12c4418c44d375173e", + "ja4": "q13d0313h3_55b375c5d22e_c7319ce65786", + "ip_address_details": { + "country": "US", + "city": "San Francisco", + "region": "California", + "region_code": "CA", + "asn": "1234", + "latitude": "37.77490", + "longitude": "-122.41940" + } } }, "api_key.updated": { @@ -3991,40 +4398,150 @@ paths: "last_id": "audit_log_yyy__20240101", "has_more": true } - /organization/invites: + /organization/costs: get: - summary: Returns a list of invites in the organization. - operationId: list-invites + summary: Get costs details for the organization. + operationId: usage-costs tags: - - Invites + - Usage parameters: - - name: limit + - name: start_time in: query - description: > - A limit on the number of objects to be returned. Limit can range - between 1 and 100, and the default is 20. + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. required: false schema: type: integer - default: 20 - - name: after + - name: bucket_width in: query - description: > - A cursor for use in pagination. `after` is an object ID that defines - your place in the list. For instance, if you make a list request and - receive 100 objects, ending with obj_foo, your subsequent call can - include after=obj_foo in order to fetch the next page of the list. + description: Width of each time bucket in response. Currently only `1d` is + supported, default to `1d`. required: false schema: type: string - responses: - "200": - description: Invites listed successfully. - content: - application/json: - schema: - $ref: "#/components/schemas/InviteListResponse" - x-oaiMeta: + enum: + - 1d + default: 1d + - name: project_ids + in: query + description: Return only costs for these projects. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the costs by the specified fields. Support fields include + `project_id`, `line_item` and any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - line_item + - name: limit + in: query + description: > + A limit on the number of buckets to be returned. Limit can range + between 1 and 180, and the default is 7. + required: false + schema: + type: integer + default: 7 + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` + field from the previous response. + schema: + type: string + responses: + "200": + description: Costs data retrieved successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/UsageResponse" + x-oaiMeta: + name: Costs + group: usage-costs + returns: A list of paginated, time bucketed + [Costs](/docs/api-reference/usage/costs_object) objects. + examples: + request: + curl: > + curl + "https://api.openai.com/v1/organization/costs?start_time=1730419200&limit=1" + \ + + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + + -H "Content-Type: application/json" + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.costs.result", + "amount": { + "value": 0.06, + "currency": "usd" + }, + "line_item": null, + "project_id": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/invites: + get: + summary: Returns a list of invites in the organization. + operationId: list-invites + tags: + - Invites + parameters: + - name: limit + in: query + description: > + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + description: > + A cursor for use in pagination. `after` is an object ID that defines + your place in the list. For instance, if you make a list request and + receive 100 objects, ending with obj_foo, your subsequent call can + include after=obj_foo in order to fetch the next page of the list. + required: false + schema: + type: string + responses: + "200": + description: Invites listed successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/InviteListResponse" + x-oaiMeta: name: List invites group: administration returns: A list of [Invite](/docs/api-reference/invite/object) objects. @@ -4036,26 +4553,25 @@ paths: \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.invite", - "id": "invite-abc", - "email": "user@example.com", - "role": "owner", - "status": "accepted", - "invited_at": 1711471533, - "expires_at": 1711471533, - "accepted_at": 1711471533 - } - ], - "first_id": "invite-abc", - "last_id": "invite-abc", - "has_more": false - } + response: | + { + "object": "list", + "data": [ + { + "object": "organization.invite", + "id": "invite-abc", + "email": "user@example.com", + "role": "owner", + "status": "accepted", + "invited_at": 1711471533, + "expires_at": 1711471533, + "accepted_at": 1711471533 + } + ], + "first_id": "invite-abc", + "last_id": "invite-abc", + "has_more": false + } post: summary: Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization. @@ -4087,20 +4603,40 @@ paths: -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" \ -d '{ - "email": "user@example.com", - "role": "owner" + "email": "anotheruser@example.com", + "role": "reader", + "projects": [ + { + "id": "project-xyz", + "role": "member" + }, + { + "id": "project-abc", + "role": "owner" + } + ] }' - response: - content: | - { - "object": "organization.invite", - "id": "invite-abc", - "email": "user@example.com", - "role": "owner", - "invited_at": 1711471533, - "expires_at": 1711471533, - "accepted_at": null - } + response: | + { + "object": "organization.invite", + "id": "invite-def", + "email": "anotheruser@example.com", + "role": "reader", + "status": "pending", + "invited_at": 1711471533, + "expires_at": 1711471533, + "accepted_at": null, + "projects": [ + { + "id": "project-xyz", + "role": "member" + }, + { + "id": "project-abc", + "role": "owner" + } + ] + } /organization/invites/{invite_id}: get: summary: Retrieves an invite. @@ -4627,6 +5163,161 @@ paths: "archived_at": 1711471533, "status": "archived" } + /organization/projects/{project_id}/rate_limits: + get: + summary: Returns the rate limits per model for a project. + operationId: list-project-rate-limits + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: limit + in: query + description: | + A limit on the number of objects to be returned. The default is 100. + required: false + schema: + type: integer + default: 100 + - name: after + in: query + description: > + A cursor for use in pagination. `after` is an object ID that defines + your place in the list. For instance, if you make a list request and + receive 100 objects, ending with obj_foo, your subsequent call can + include after=obj_foo in order to fetch the next page of the list. + required: false + schema: + type: string + - name: before + in: query + description: > + A cursor for use in pagination. `before` is an object ID that + defines your place in the list. For instance, if you make a list + request and receive 100 objects, beginning with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the + previous page of the list. + required: false + schema: + type: string + responses: + "200": + description: Project rate limits listed successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/ProjectRateLimitListResponse" + x-oaiMeta: + name: List project rate limits + group: administration + returns: A list of + [ProjectRateLimit](/docs/api-reference/project-rate-limits/object) + objects. + examples: + request: + curl: > + curl + https://api.openai.com/v1/organization/projects/proj_abc/rate_limits?after=rl_xxx&limit=20 + \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + response: | + { + "object": "list", + "data": [ + { + "object": "project.rate_limit", + "id": "rl-ada", + "model": "ada", + "max_requests_per_1_minute": 600, + "max_tokens_per_1_minute": 150000, + "max_images_per_1_minute": 10 + } + ], + "first_id": "rl-ada", + "last_id": "rl-ada", + "has_more": false + } + error_response: | + { + "code": 404, + "message": "The project {project_id} was not found" + } + /organization/projects/{project_id}/rate_limits/{rate_limit_id}: + post: + summary: Updates a project rate limit. + operationId: update-project-rate-limits + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: rate_limit_id + in: path + description: The ID of the rate limit. + required: true + schema: + type: string + requestBody: + description: The project rate limit update request payload. + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ProjectRateLimitUpdateRequest" + responses: + "200": + description: Project rate limit updated successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/ProjectRateLimit" + "400": + description: Error response for various conditions. + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + x-oaiMeta: + name: Modify project rate limit + group: administration + returns: The updated + [ProjectRateLimit](/docs/api-reference/project-rate-limits/object) + object. + examples: + request: + curl: > + curl -X POST + https://api.openai.com/v1/organization/projects/proj_abc/rate_limits/rl_xxx + \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "max_requests_per_1_minute": 500 + }' + response: | + { + "object": "project.rate_limit", + "id": "rl-ada", + "model": "ada", + "max_requests_per_1_minute": 600, + "max_tokens_per_1_minute": 150000, + "max_images_per_1_minute": 10 + } + error_response: | + { + "code": 404, + "message": "The project {project_id} was not found" + } /organization/projects/{project_id}/service_accounts: get: summary: Returns a list of service accounts in the project. @@ -5173,164 +5864,1269 @@ paths: "id": "user_abc", "deleted": true } - /organization/users: + /organization/usage/audio_speeches: get: - summary: Lists all of the users in the organization. - operationId: list-users + summary: Get audio speeches usage details for the organization. + operationId: usage-audio-speeches tags: - - Users + - Usage parameters: - - name: limit + - name: start_time in: query - description: > - A limit on the number of objects to be returned. Limit can range - between 1 and 100, and the default is 20. - required: false + description: Start time (Unix seconds) of the query time range, inclusive. + required: true schema: type: integer - default: 20 - - name: after + - name: end_time in: query - description: > - A cursor for use in pagination. `after` is an object ID that defines - your place in the list. For instance, if you make a list request and - receive 100 objects, ending with obj_foo, your subsequent call can - include after=obj_foo in order to fetch the next page of the list. + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and + `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields + include `project_id`, `user_id`, `api_key_id`, `model` or any + combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` + field from the previous response. schema: type: string responses: "200": - description: Users listed successfully. + description: Usage data retrieved successfully. content: application/json: schema: - $ref: "#/components/schemas/UserListResponse" + $ref: "#/components/schemas/UsageResponse" x-oaiMeta: - name: List users - group: administration - returns: A list of [User](/docs/api-reference/users/object) objects. + name: Audio speeches + group: usage-audio-speeches + returns: A list of paginated, time bucketed [Audio speeches + usage](/docs/api-reference/usage/audio_speeches_object) objects. examples: request: curl: > curl - https://api.openai.com/v1/organization/users?after=user_abc&limit=20 + "https://api.openai.com/v1/organization/usage/audio_speeches?start_time=1730419200&limit=1" \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - ], - "first_id": "user-abc", - "last_id": "user-xyz", - "has_more": false - } - /organization/users/{user_id}: + + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + + -H "Content-Type: application/json" + response: > + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.audio_speeches.result", + "characters": 45, + "num_model_requests": 1, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/audio_transcriptions: get: - summary: Retrieves a user by their identifier. - operationId: retrieve-user + summary: Get audio transcriptions usage details for the organization. + operationId: usage-audio-transcriptions tags: - - Users + - Usage parameters: - - name: user_id - in: path - description: The ID of the user. + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and + `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields + include `project_id`, `user_id`, `api_key_id`, `model` or any + combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` + field from the previous response. schema: type: string responses: "200": - description: User retrieved successfully. + description: Usage data retrieved successfully. content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: "#/components/schemas/UsageResponse" x-oaiMeta: - name: Retrieve user - group: administration - returns: The [User](/docs/api-reference/users/object) object matching the - specified ID. + name: Audio transcriptions + group: usage-audio-transcriptions + returns: A list of paginated, time bucketed [Audio transcriptions + usage](/docs/api-reference/usage/audio_transcriptions_object) objects. examples: request: - curl: | - curl https://api.openai.com/v1/organization/users/user_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - post: - summary: Modifies a user's role in the organization. - operationId: modify-user + curl: > + curl + "https://api.openai.com/v1/organization/usage/audio_transcriptions?start_time=1730419200&limit=1" + \ + + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + + -H "Content-Type: application/json" + response: > + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.audio_transcriptions.result", + "seconds": 20, + "num_model_requests": 1, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/code_interpreter_sessions: + get: + summary: Get code interpreter sessions usage details for the organization. + operationId: usage-code-interpreter-sessions tags: - - Users + - Usage parameters: - - name: user_id - in: path - description: The ID of the user. + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and + `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields + include `project_id`. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` + field from the previous response. schema: type: string - requestBody: - description: The new user role to modify. This must be one of `owner` or `member`. - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/UserRoleUpdateRequest" responses: "200": - description: User role updated successfully. + description: Usage data retrieved successfully. content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: "#/components/schemas/UsageResponse" x-oaiMeta: - name: Modify user - group: administration - returns: The updated [User](/docs/api-reference/users/object) object. + name: Code interpreter sessions + group: usage-code-interpreter-sessions + returns: A list of paginated, time bucketed [Code interpreter sessions + usage](/docs/api-reference/usage/code_interpreter_sessions_object) + objects. examples: request: curl: > - curl -X POST https://api.openai.com/v1/organization/users/user_abc + curl + "https://api.openai.com/v1/organization/usage/code_interpreter_sessions?start_time=1730419200&limit=1" \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "role": "owner" - }' - response: - content: | - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - delete: - summary: Deletes a user from the organization. - operationId: delete-user - tags: + + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + + -H "Content-Type: application/json" + response: > + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.code_interpreter_sessions.result", + "sessions": 1, + "project_id": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/completions: + get: + summary: Get completions usage details for the organization. + operationId: usage-completions + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and + `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: batch + in: query + description: > + If `true`, return batch jobs only. If `false`, return non-batch jobs + only. By default, return both. + required: false + schema: + type: boolean + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields + include `project_id`, `user_id`, `api_key_id`, `model`, `batch` or + any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - batch + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` + field from the previous response. + schema: + type: string + responses: + "200": + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/UsageResponse" + x-oaiMeta: + name: Completions + group: usage-completions + returns: A list of paginated, time bucketed [Completions + usage](/docs/api-reference/usage/completions_object) objects. + examples: + request: + curl: > + curl + "https://api.openai.com/v1/organization/usage/completions?start_time=1730419200&limit=1" + \ + + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + + -H "Content-Type: application/json" + response: > + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.completions.result", + "input_tokens": 1000, + "output_tokens": 500, + "input_cached_tokens": 800, + "input_audio_tokens": 0, + "output_audio_tokens": 0, + "num_model_requests": 5, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null, + "batch": null + } + ] + } + ], + "has_more": true, + "next_page": "page_AAAAAGdGxdEiJdKOAAAAAGcqsYA=" + } + /organization/usage/embeddings: + get: + summary: Get embeddings usage details for the organization. + operationId: usage-embeddings + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and + `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields + include `project_id`, `user_id`, `api_key_id`, `model` or any + combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` + field from the previous response. + schema: + type: string + responses: + "200": + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/UsageResponse" + x-oaiMeta: + name: Embeddings + group: usage-embeddings + returns: A list of paginated, time bucketed [Embeddings + usage](/docs/api-reference/usage/embeddings_object) objects. + examples: + request: + curl: > + curl + "https://api.openai.com/v1/organization/usage/embeddings?start_time=1730419200&limit=1" + \ + + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + + -H "Content-Type: application/json" + response: > + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.embeddings.result", + "input_tokens": 16, + "num_model_requests": 2, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/images: + get: + summary: Get images usage details for the organization. + operationId: usage-images + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and + `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: sources + in: query + description: Return only usages for these sources. Possible values are + `image.generation`, `image.edit`, `image.variation` or any + combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - image.generation + - image.edit + - image.variation + - name: sizes + in: query + description: Return only usages for these image sizes. Possible values are + `256x256`, `512x512`, `1024x1024`, `1792x1792`, `1024x1792` or any + combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - 256x256 + - 512x512 + - 1024x1024 + - 1792x1792 + - 1024x1792 + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields + include `project_id`, `user_id`, `api_key_id`, `model`, `size`, + `source` or any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - size + - source + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` + field from the previous response. + schema: + type: string + responses: + "200": + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/UsageResponse" + x-oaiMeta: + name: Images + group: usage-images + returns: A list of paginated, time bucketed [Images + usage](/docs/api-reference/usage/images_object) objects. + examples: + request: + curl: > + curl + "https://api.openai.com/v1/organization/usage/images?start_time=1730419200&limit=1" + \ + + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + + -H "Content-Type: application/json" + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.images.result", + "images": 2, + "num_model_requests": 2, + "size": null, + "source": null, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/moderations: + get: + summary: Get moderations usage details for the organization. + operationId: usage-moderations + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and + `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields + include `project_id`, `user_id`, `api_key_id`, `model` or any + combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` + field from the previous response. + schema: + type: string + responses: + "200": + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/UsageResponse" + x-oaiMeta: + name: Moderations + group: usage-moderations + returns: A list of paginated, time bucketed [Moderations + usage](/docs/api-reference/usage/moderations_object) objects. + examples: + request: + curl: > + curl + "https://api.openai.com/v1/organization/usage/moderations?start_time=1730419200&limit=1" + \ + + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + + -H "Content-Type: application/json" + response: > + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.moderations.result", + "input_tokens": 16, + "num_model_requests": 2, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/vector_stores: + get: + summary: Get vector stores usage details for the organization. + operationId: usage-vector-stores + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and + `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields + include `project_id`. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` + field from the previous response. + schema: + type: string + responses: + "200": + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/UsageResponse" + x-oaiMeta: + name: Vector stores + group: usage-vector-stores + returns: A list of paginated, time bucketed [Vector stores + usage](/docs/api-reference/usage/vector_stores_object) objects. + examples: + request: + curl: > + curl + "https://api.openai.com/v1/organization/usage/vector_stores?start_time=1730419200&limit=1" + \ + + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + + -H "Content-Type: application/json" + response: > + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.vector_stores.result", + "usage_bytes": 1024, + "project_id": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/users: + get: + summary: Lists all of the users in the organization. + operationId: list-users + tags: + - Users + parameters: + - name: limit + in: query + description: > + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + description: > + A cursor for use in pagination. `after` is an object ID that defines + your place in the list. For instance, if you make a list request and + receive 100 objects, ending with obj_foo, your subsequent call can + include after=obj_foo in order to fetch the next page of the list. + required: false + schema: + type: string + responses: + "200": + description: Users listed successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/UserListResponse" + x-oaiMeta: + name: List users + group: administration + returns: A list of [User](/docs/api-reference/users/object) objects. + examples: + request: + curl: > + curl + https://api.openai.com/v1/organization/users?after=user_abc&limit=20 + \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + response: + content: | + { + "object": "list", + "data": [ + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + ], + "first_id": "user-abc", + "last_id": "user-xyz", + "has_more": false + } + /organization/users/{user_id}: + get: + summary: Retrieves a user by their identifier. + operationId: retrieve-user + tags: + - Users + parameters: + - name: user_id + in: path + description: The ID of the user. + required: true + schema: + type: string + responses: + "200": + description: User retrieved successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/User" + x-oaiMeta: + name: Retrieve user + group: administration + returns: The [User](/docs/api-reference/users/object) object matching the + specified ID. + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/users/user_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + response: + content: | + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + post: + summary: Modifies a user's role in the organization. + operationId: modify-user + tags: + - Users + parameters: + - name: user_id + in: path + description: The ID of the user. + required: true + schema: + type: string + requestBody: + description: The new user role to modify. This must be one of `owner` or `member`. + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/UserRoleUpdateRequest" + responses: + "200": + description: User role updated successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/User" + x-oaiMeta: + name: Modify user + group: administration + returns: The updated [User](/docs/api-reference/users/object) object. + examples: + request: + curl: > + curl -X POST https://api.openai.com/v1/organization/users/user_abc + \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role": "owner" + }' + response: + content: | + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + delete: + summary: Deletes a user from the organization. + operationId: delete-user + tags: - Users parameters: - name: user_id @@ -5364,6 +7160,79 @@ paths: "id": "user_abc", "deleted": true } + /realtime/sessions: + post: + summary: > + Create an ephemeral API token for use in client-side applications with + the + + Realtime API. Can be configured with the same session parameters as the + + `session.update` client event. + + + It responds with a session object, plus a `client_secret` key which + contains + + a usable ephemeral API token that can be used to authenticate browser + clients + + for the Realtime API. + operationId: create-realtime-session + tags: + - Realtime + requestBody: + description: Create an ephemeral API key with the given session configuration. + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/RealtimeSessionCreateRequest" + responses: + "200": + description: Session created successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/RealtimeSessionCreateResponse" + x-oaiMeta: + name: Create session + group: realtime + returns: The created Realtime session object, plus an ephemeral key + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/realtime/sessions \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "model": "gpt-4o-realtime-preview-2024-12-17", + "modalities": ["audio", "text"], + "instructions": "You are a friendly assistant." + }' + response: | + { + "id": "sess_001", + "object": "realtime.session", + "model": "gpt-4o-realtime-preview-2024-12-17", + "modalities": ["audio", "text"], + "instructions": "You are a friendly assistant.", + "voice": "alloy", + "input_audio_format": "pcm16", + "output_audio_format": "pcm16", + "input_audio_transcription": { + "model": "whisper-1" + }, + "turn_detection": null, + "tools": [], + "tool_choice": "none", + "temperature": 0.7, + "max_response_output_tokens": 200, + "client_secret": { + "value": "ek_abc123", + "expires_at": 1234567890 + } + } /threads: post: operationId: createThread @@ -6229,7 +8098,7 @@ paths: description: > A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list - request and receive 100 objects, ending with obj_foo, your + request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. schema: @@ -6728,7 +8597,7 @@ paths: description: > A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list - request and receive 100 objects, ending with obj_foo, your + request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. schema: @@ -6900,7 +8769,7 @@ paths: See the [file search tool - documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. schema: type: array @@ -7718,7 +9587,7 @@ paths: description: > A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list - request and receive 100 objects, ending with obj_foo, your + request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. schema: @@ -7733,7 +9602,7 @@ paths: See the [file search tool - documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. schema: type: array @@ -7856,7 +9725,7 @@ paths: See the [file search tool - documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. schema: type: array @@ -8293,7 +10162,7 @@ paths: Please refer to documentation for the supported MIME types for your use case: - - [Assistants](/docs/assistants/tools/file-search/supported-files) + - [Assistants](/docs/assistants/tools/file-search#supported-files) For guidance on the proper filename extensions for each purpose, please @@ -8554,7 +10423,7 @@ paths: description: > A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list - request and receive 100 objects, ending with obj_foo, your + request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. schema: @@ -8944,7 +10813,7 @@ paths: description: > A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list - request and receive 100 objects, ending with obj_foo, your + request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. schema: @@ -9579,7 +11448,7 @@ paths: description: > A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list - request and receive 100 objects, ending with obj_foo, your + request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. schema: @@ -9680,6 +11549,66 @@ components: format: binary required: - data + AdminApiKey: + type: object + properties: + object: + type: string + example: organization.admin_api_key + id: + type: string + example: key_abc + name: + type: string + example: Administration Key + redacted_value: + type: string + example: sk-admin...def + value: + type: string + example: sk-admin-1234abcd + created_at: + type: integer + format: int64 + example: 1711471533 + owner: + type: object + properties: + type: + type: string + example: service_account + id: + type: string + example: sa_456 + name: + type: string + example: My Service Account + created_at: + type: integer + format: int64 + example: 1711471533 + role: + type: string + example: member + ApiKeyList: + type: object + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: "#/components/schemas/AdminApiKey" + has_more: + type: boolean + example: false + first_id: + type: string + example: key_abc + last_id: + type: string + example: key_xyz AssistantObject: type: object title: Assistant @@ -9713,8 +11642,8 @@ components: description: > ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your - available models, or see our [Model overview](/docs/models/overview) - for descriptions of them. + available models, or see our [Model overview](/docs/models) for + descriptions of them. type: string instructions: description: > @@ -9845,8 +11774,8 @@ components: AssistantsApiResponseFormatOption: description: > Specifies the format that the model must output. Compatible with - [GPT-4o](/docs/models/gpt-4o), [GPT-4 - Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models + [GPT-4o](/docs/models#gpt-4o), [GPT-4 + Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. @@ -10020,7 +11949,7 @@ components: Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool - documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: "#/components/schemas/FileSearchRankingOptions" @@ -10251,6 +12180,44 @@ components: id: type: string description: The project ID. + rate_limit.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The rate limit ID + changes_requested: + type: object + description: The payload used to update the rate limits. + properties: + max_requests_per_1_minute: + type: integer + description: The maximum requests per minute. + max_tokens_per_1_minute: + type: integer + description: The maximum tokens per minute. + max_images_per_1_minute: + type: integer + description: The maximum images per minute. Only relevant for certain models. + max_audio_megabytes_per_1_minute: + type: integer + description: The maximum audio megabytes per minute. Only relevant for certain + models. + max_requests_per_1_day: + type: integer + description: The maximum requests per day. Only relevant for certain models. + batch_1_day_max_input_tokens: + type: integer + description: The maximum batch input tokens per day. Only relevant for certain + models. + rate_limit.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The rate limit ID service_account.created: type: object description: The details for events with this `type`. @@ -10432,6 +12399,8 @@ components: - service_account.created - service_account.updated - service_account.deleted + - rate_limit.updated + - rate_limit.deleted - user.added - user.updated - user.deleted @@ -10827,6 +12796,8 @@ components: ChatCompletionRequestAssistantMessage: type: object title: Assistant message + description: | + Messages sent by the model in response to user messages. properties: content: x-oaiExpandable: true @@ -10901,6 +12872,43 @@ components: - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartText" - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartRefusal" x-oaiExpandable: true + ChatCompletionRequestDeveloperMessage: + type: object + title: Developer message + description: > + Developer-provided instructions that the model should follow, regardless + of + + messages sent by the user. With o1 models and newer, `developer` + messages + + replace the previous `system` messages. + properties: + content: + description: The contents of the developer message. + oneOf: + - type: string + description: The contents of the developer message. + title: Text content + - type: array + description: An array of content parts with a defined type. For developer + messages, only type `text` is supported. + title: Array of content parts + items: + $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartText" + minItems: 1 + role: + type: string + enum: + - developer + description: The role of the messages author, in this case `developer`. + name: + type: string + description: An optional name for the participant. Provides the model + information to differentiate between participants of the same role. + required: + - content + - role ChatCompletionRequestFunctionMessage: type: object title: Function message @@ -10924,6 +12932,7 @@ components: - name ChatCompletionRequestMessage: oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestDeveloperMessage" - $ref: "#/components/schemas/ChatCompletionRequestSystemMessage" - $ref: "#/components/schemas/ChatCompletionRequestUserMessage" - $ref: "#/components/schemas/ChatCompletionRequestAssistantMessage" @@ -10982,7 +12991,7 @@ components: detail: type: string description: Specifies the detail level of the image. Learn more in the [Vision - guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). enum: - auto - low @@ -11028,6 +13037,14 @@ components: ChatCompletionRequestSystemMessage: type: object title: System message + description: > + Developer-provided instructions that the model should follow, regardless + of + + messages sent by the user. With o1 models and newer, use `developer` + messages + + for this purpose instead. properties: content: description: The contents of the system message. @@ -11094,6 +13111,9 @@ components: ChatCompletionRequestUserMessage: type: object title: User message + description: | + Messages sent by an end user, containing prompts or additional context + information. properties: content: description: | @@ -11398,12 +13418,30 @@ components: type: object description: Breakdown of tokens used in a completion. properties: + accepted_prediction_tokens: + type: integer + description: | + When using Predicted Outputs, the number of tokens in the + prediction that appeared in the completion. audio_tokens: type: integer description: Audio input tokens generated by the model. reasoning_tokens: type: integer description: Tokens generated by the model for reasoning. + rejected_prediction_tokens: + type: integer + description: > + When using Predicted Outputs, the number of tokens in the + + prediction that did not appear in the completion. However, like + + reasoning tokens, these tokens are still counted in the total + + completion tokens for purposes of billing, output, and context + window + + limits. prompt_tokens_details: type: object description: Breakdown of tokens used in the prompt. @@ -11415,9 +13453,52 @@ components: type: integer description: Cached tokens present in the prompt. required: - - prompt_tokens - - completion_tokens - - total_tokens + - prompt_tokens + - completion_tokens + - total_tokens + CostsResult: + type: object + description: The aggregated costs details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.costs.result + amount: + type: object + description: The monetary value in its associated currency. + properties: + value: + type: number + description: The numeric value of the cost. + currency: + type: string + description: Lowercase ISO-4217 currency e.g. "usd" + line_item: + type: string + nullable: true + description: When `group_by=line_item`, this field provides the line item of the + grouped costs result. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of + the grouped costs result. + required: + - object + - sessions + x-oaiMeta: + name: Costs object + example: | + { + "object": "organization.costs.result", + "amount": { + "value": 0.06, + "currency": "usd" + }, + "line_item": "Image models", + "project_id": "proj_abc" + } CreateAssistantRequest: type: object additionalProperties: false @@ -11426,17 +13507,17 @@ components: description: > ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your - available models, or see our [Model overview](/docs/models/overview) - for descriptions of them. + available models, or see our [Model overview](/docs/models) for + descriptions of them. example: gpt-4o anyOf: - type: string - type: string enum: - gpt-4o + - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - - gpt-4o-2024-08-06 - gpt-4o-mini - gpt-4o-mini-2024-07-18 - gpt-4-turbo @@ -11760,7 +13841,9 @@ components: "completion_tokens": 17, "total_tokens": 99, "completion_tokens_details": { - "reasoning_tokens": 0 + "reasoning_tokens": 0, + "accepted_prediction_tokens": 0, + "rejected_prediction_tokens": 0 } } } @@ -11792,7 +13875,9 @@ components: "completion_tokens": 12, "total_tokens": 21, "completion_tokens_details": { - "reasoning_tokens": 0 + "reasoning_tokens": 0, + "accepted_prediction_tokens": 0, + "rejected_prediction_tokens": 0 } } } @@ -11816,25 +13901,28 @@ components: $ref: "#/components/schemas/ChatCompletionRequestMessage" model: description: ID of the model to use. See the [model endpoint - compatibility](/docs/models/model-endpoint-compatibility) table for + compatibility](/docs/models#model-endpoint-compatibility) table for details on which models work with the Chat API. example: gpt-4o anyOf: - type: string - type: string enum: + - o1 + - o1-2024-12-17 - o1-preview - o1-preview-2024-09-12 - o1-mini - o1-mini-2024-09-12 - gpt-4o + - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - - gpt-4o-2024-08-06 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - gpt-4o-audio-preview - gpt-4o-audio-preview-2024-10-01 + - gpt-4o-audio-preview-2024-12-17 + - gpt-4o-mini-audio-preview + - gpt-4o-mini-audio-preview-2024-12-17 - chatgpt-4o-latest - gpt-4o-mini - gpt-4o-mini-2024-07-18 @@ -11864,9 +13952,33 @@ components: nullable: true description: > Whether or not to store the output of this chat completion request + for + + use in our [model distillation](/docs/guides/distillation) or - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + reasoning_effort: + type: string + enum: + - low + - medium + - high + default: medium + description: > + **o1 models only** + + + Constrains effort on reasoning for + + [reasoning + models](https://platform.openai.com/docs/guides/reasoning). + + Currently supported values are `low`, `medium`, and `high`. Reducing + + reasoning effort can result in faster responses and fewer tokens + used + + on reasoning in a response. metadata: type: object nullable: true @@ -11883,12 +13995,11 @@ components: nullable: true description: > Number between -2.0 and 2.0. Positive values penalize new tokens - based on their existing frequency in the text so far, decreasing the - model's likelihood to repeat the same line verbatim. + based on + their existing frequency in the text so far, decreasing the model's - [See more information about frequency and presence - penalties.](/docs/guides/text-generation/parameter-details) + likelihood to repeat the same line verbatim. logit_bias: type: object x-oaiTypeLabel: map @@ -11902,24 +14013,41 @@ components: Accepts a JSON object that maps tokens (specified by their token ID - in the tokenizer) to an associated bias value from -100 to 100. - Mathematically, the bias is added to the logits generated by the - model prior to sampling. The exact effect will vary per model, but - values between -1 and 1 should decrease or increase likelihood of - selection; values like -100 or 100 should result in a ban or - exclusive selection of the relevant token. + in the + + tokenizer) to an associated bias value from -100 to 100. + Mathematically, + + the bias is added to the logits generated by the model prior to + sampling. + + The exact effect will vary per model, but values between -1 and 1 + should + + decrease or increase likelihood of selection; values like -100 or + 100 + + should result in a ban or exclusive selection of the relevant token. logprobs: - description: Whether to return log probabilities of the output tokens or not. If - true, returns the log probabilities of each output token returned in - the `content` of `message`. + description: > + Whether to return log probabilities of the output tokens or not. If + true, + + returns the log probabilities of each output token returned in the + + `content` of `message`. type: boolean default: false nullable: true top_logprobs: - description: An integer between 0 and 20 specifying the number of most likely - tokens to return at each token position, each with an associated log - probability. `logprobs` must be set to `true` if this parameter is - used. + description: > + An integer between 0 and 20 specifying the number of most likely + tokens to + + return at each token position, each with an associated log + probability. + + `logprobs` must be set to `true` if this parameter is used. type: integer minimum: 0 maximum: 20 @@ -11927,13 +14055,17 @@ components: max_tokens: description: > The maximum number of [tokens](/tokenizer) that can be generated in - the chat completion. This value can be used to control + the + + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. This value is now deprecated in favor of `max_completion_tokens`, - and is not compatible with [o1 series - models](/docs/guides/reasoning). + and is + + not compatible with [o1 series models](/docs/guides/reasoning). type: integer nullable: true deprecated: true @@ -11957,6 +14089,21 @@ components: minimize costs. modalities: $ref: "#/components/schemas/ChatCompletionModalities" + prediction: + nullable: true + x-oaiExpandable: true + description: > + Configuration for a [Predicted + Output](/docs/guides/predicted-outputs), + + which can greatly improve response times when large parts of the + model + + response are known ahead of time. This is most common when you are + + regenerating a file with only minor changes to most of the content. + oneOf: + - $ref: "#/components/schemas/PredictionContent" audio: type: object nullable: true @@ -11974,14 +14121,18 @@ components: type: string enum: - alloy + - ash + - ballad + - coral - echo - - fable - - onyx - - nova + - sage - shimmer - description: | - Specifies the voice type. Supported voices are `alloy`, `echo`, - `fable`, `onyx`, `nova`, and `shimmer`. + - verse + description: > + The voice the model uses to respond. Supported voices are `ash`, + `ballad`, `coral`, `sage`, and `verse` (also supported but not + recommended are `alloy`, `echo`, and `shimmer`; these voices are + less expressive). format: type: string enum: @@ -11994,7 +14145,7 @@ components: Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, - `opus`, or `pcm16`. + `opus`, or `pcm16`. presence_penalty: type: number default: 0 @@ -12003,39 +14154,51 @@ components: nullable: true description: > Number between -2.0 and 2.0. Positive values penalize new tokens - based on whether they appear in the text so far, increasing the - model's likelihood to talk about new topics. + based on + whether they appear in the text so far, increasing the model's + likelihood - [See more information about frequency and presence - penalties.](/docs/guides/text-generation/parameter-details) + to talk about new topics. response_format: description: > An object specifying the format that the model must output. - Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o - mini](/docs/models/gpt-4o-mini), [GPT-4 - Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo - models newer than `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied - JSON schema. Learn more in the [Structured Outputs + JSON + + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). Setting to `{ "type": "json_object" }` enables JSON mode, which - ensures the message the model generates is valid JSON. + ensures + + the message the model generates is valid JSON. **Important:** when using JSON mode, you **must** also instruct the - model to produce JSON yourself via a system or user message. Without - this, the model may generate an unending stream of whitespace until - the generation reaches the token limit, resulting in a long-running - and seemingly "stuck" request. Also note that the message content - may be partially cut off if `finish_reason="length"`, which - indicates the generation exceeded `max_tokens` or the conversation - exceeded the max context length. + model + + to produce JSON yourself via a system or user message. Without this, + the + + model may generate an unending stream of whitespace until the + generation + + reaches the token limit, resulting in a long-running and seemingly + "stuck" + + request. Also note that the message content may be partially cut off + if + + `finish_reason="length"`, which indicates the generation exceeded + + `max_tokens` or the conversation exceeded the max context length. oneOf: - $ref: "#/components/schemas/ResponseFormatText" - $ref: "#/components/schemas/ResponseFormatJsonObject" @@ -12063,7 +14226,7 @@ components: Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. + - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - When not set, the default behavior is 'auto'. @@ -12112,7 +14275,6 @@ components: like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. top_p: type: number @@ -12123,9 +14285,15 @@ components: nullable: true description: > An alternative to sampling with temperature, called nucleus - sampling, where the model considers the results of the tokens with - top_p probability mass. So 0.1 means only the tokens comprising the - top 10% probability mass are considered. + sampling, + + where the model considers the results of the tokens with top_p + probability + + mass. So 0.1 means only the tokens comprising the top 10% + probability mass + + are considered. We generally recommend altering this or `temperature` but not both. @@ -12148,7 +14316,7 @@ components: description: > A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn - more](/docs/guides/safety-best-practices/end-user-ids). + more](/docs/guides/safety-best-practices#end-user-ids). function_call: deprecated: true description: > @@ -12157,18 +14325,29 @@ components: Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead - generates a message. + generates a + + message. + `auto` means the model can pick between generating a message or - calling a function. + calling a + + function. + Specifying a particular function via `{"name": "my_function"}` - forces the model to call that function. + forces the + + model to call that function. `none` is the default when no functions are present. `auto` is the - default if functions are present. + default + + if functions are present. oneOf: - type: string description: > @@ -12329,7 +14508,9 @@ components: "cached_tokens": 0 }, "completion_tokens_details": { - "reasoning_tokens": 0 + "reasoning_tokens": 0, + "accepted_prediction_tokens": 0, + "rejected_prediction_tokens": 0 } }, "system_fingerprint": "fp_6b68a8204b" @@ -12491,8 +14672,8 @@ components: description: > ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your - available models, or see our [Model overview](/docs/models/overview) - for descriptions of them. + available models, or see our [Model overview](/docs/models) for + descriptions of them. anyOf: - type: string - type: string @@ -12573,7 +14754,7 @@ components: [See more information about frequency and presence - penalties.](/docs/guides/text-generation/parameter-details) + penalties.](/docs/guides/text-generation) logit_bias: type: object x-oaiTypeLabel: map @@ -12655,7 +14836,7 @@ components: [See more information about frequency and presence - penalties.](/docs/guides/text-generation/parameter-details) + penalties.](/docs/guides/text-generation) seed: type: integer minimum: -9223372036854776000 @@ -12744,7 +14925,7 @@ components: description: > A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn - more](/docs/guides/safety-best-practices/end-user-ids). + more](/docs/guides/safety-best-practices#end-user-ids). required: - model - prompt @@ -12877,7 +15058,8 @@ components: cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) - for counting tokens. + for counting tokens. Some models may also impose a limit on total + number of tokens summed across inputs. example: The quick brown fox jumped over the lazy dog oneOf: - type: string @@ -12919,8 +15101,8 @@ components: description: > ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your - available models, or see our [Model overview](/docs/models/overview) - for descriptions of them. + available models, or see our [Model overview](/docs/models) for + descriptions of them. example: text-embedding-3-small anyOf: - type: string @@ -12951,7 +15133,7 @@ components: description: > A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn - more](/docs/guides/safety-best-practices/end-user-ids). + more](/docs/guides/safety-best-practices#end-user-ids). required: - model - input @@ -13025,7 +15207,7 @@ components: The name of the model to fine-tune. You can select one of the [supported - models](/docs/guides/fine-tuning/which-models-can-be-fine-tuned). + models](/docs/guides/fine-tuning#which-models-can-be-fine-tuned). example: gpt-4o-mini anyOf: - type: string @@ -13050,8 +15232,10 @@ components: The contents of the file should differ depending on if the model - uses the [chat](/docs/api-reference/fine-tuning/chat-input) or + uses the [chat](/docs/api-reference/fine-tuning/chat-input), [completions](/docs/api-reference/fine-tuning/completions-input) + format, or if the fine-tuning method uses the + [preference](/docs/api-reference/fine-tuning/preference-input) format. @@ -13061,7 +15245,11 @@ components: example: file-abc123 hyperparameters: type: object - description: The hyperparameters used for the fine-tuning job. + description: > + The hyperparameters used for the fine-tuning job. + + This value is now deprecated in favor of `method`, and should be + passed in under the `method` parameter. properties: batch_size: description: > @@ -13105,6 +15293,7 @@ components: minimum: 1 maximum: 50 default: auto + deprecated: true suffix: description: > A string of up to 64 characters that will be added to your @@ -13219,6 +15408,8 @@ components: minimum: 0 maximum: 2147483647 example: 42 + method: + $ref: "#/components/schemas/FineTuneMethod" required: - model - training_file @@ -13290,7 +15481,7 @@ components: description: > A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn - more](/docs/guides/safety-best-practices/end-user-ids). + more](/docs/guides/safety-best-practices#end-user-ids). required: - prompt - image @@ -13377,7 +15568,7 @@ components: description: > A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn - more](/docs/guides/safety-best-practices/end-user-ids). + more](/docs/guides/safety-best-practices#end-user-ids). required: - prompt CreateImageVariationRequest: @@ -13437,7 +15628,7 @@ components: description: > A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn - more](/docs/guides/safety-best-practices/end-user-ids). + more](/docs/guides/safety-best-practices#end-user-ids). required: - image CreateMessageRequest: @@ -13471,7 +15662,7 @@ components: description: An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible - models](/docs/models/overview). + models](/docs/models). title: Array of content parts items: oneOf: @@ -13580,7 +15771,7 @@ components: description: | The content moderation model you would like to use. Learn more in [the moderation guide](/docs/guides/moderation), and learn about - available models [here](/docs/models/moderation). + available models [here](/docs/models#moderation). nullable: false default: omni-moderation-latest example: omni-moderation-2024-09-26 @@ -13988,9 +16179,9 @@ components: - type: string enum: - gpt-4o + - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - - gpt-4o-2024-08-06 - gpt-4o-mini - gpt-4o-mini-2024-07-18 - gpt-4-turbo @@ -14126,7 +16317,7 @@ components: properties: model: description: > - One of the available [TTS models](/docs/models/tts): `tts-1` or + One of the available [TTS models](/docs/models#tts): `tts-1` or `tts-1-hd` anyOf: - type: string @@ -14142,16 +16333,19 @@ components: maxLength: 4096 voice: description: The voice to use when generating the audio. Supported voices are - `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of - the voices are available in the [Text to speech - guide](/docs/guides/text-to-speech/voice-options). + `alloy`, `ash`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and + `shimmer`. Previews of the voices are available in the [Text to + speech guide](/docs/guides/text-to-speech#voice-options). type: string enum: - alloy + - ash + - coral - echo - fable - onyx - nova + - sage - shimmer response_format: description: The format to audio in. Supported formats are `mp3`, `opus`, `aac`, @@ -14198,9 +16392,9 @@ components: - type: string enum: - gpt-4o + - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - - gpt-4o-2024-08-06 - gpt-4o-mini - gpt-4o-mini-2024-07-18 - gpt-4-turbo @@ -14525,7 +16719,7 @@ components: prompt: description: > An optional text to guide the model's style or continue a previous - audio segment. The [prompt](/docs/guides/speech-to-text/prompting) + audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should match the audio language. type: string response_format: @@ -14656,7 +16850,7 @@ components: prompt: description: > An optional text to guide the model's style or continue a previous - audio segment. The [prompt](/docs/guides/speech-to-text/prompting) + audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should be in English. type: string response_format: @@ -15003,10 +17197,10 @@ components: required: - event - data - description: Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. + description: Occurs when an [error](/docs/guides/error-codes#api-errors) occurs. This can happen due to an internal server error or a timeout. x-oaiMeta: - dataDescription: "`data` is an [error](/docs/guides/error-codes/api-errors)" + dataDescription: "`data` is an [error](/docs/guides/error-codes#api-errors)" ErrorResponse: type: object properties: @@ -15023,7 +17217,7 @@ components: See the [file search tool - documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. properties: ranker: @@ -15056,9 +17250,10 @@ components: - $ref: "#/components/schemas/ChatCompletionRequestAssistantMessage" required: - role - FinetuneChatRequestInput: + FineTuneChatRequestInput: type: object - description: The per-line training example of a fine-tuning input file for chat models + description: The per-line training example of a fine-tuning input file for chat + models using the supervised method. properties: messages: type: array @@ -15087,7 +17282,7 @@ components: items: $ref: "#/components/schemas/ChatCompletionFunctions" x-oaiMeta: - name: Training format for chat models + name: Training format for chat models using the supervised method example: > { "messages": [ @@ -15128,7 +17323,7 @@ components: } ] } - FinetuneCompletionRequestInput: + FineTuneCompletionRequestInput: type: object description: The per-line training example of a fine-tuning input file for completions models @@ -15146,6 +17341,190 @@ components: "prompt": "What is the answer to 2+2", "completion": "4" } + FineTuneDPOMethod: + type: object + description: Configuration for the DPO fine-tuning method. + properties: + hyperparameters: + type: object + description: The hyperparameters used for the fine-tuning job. + properties: + beta: + description: > + The beta value for the DPO method. A higher beta value will + increase the weight of the penalty between the policy and + reference model. + oneOf: + - type: string + enum: + - auto + - type: number + minimum: 0 + maximum: 2 + exclusiveMinimum: true + default: auto + batch_size: + description: > + Number of examples in each batch. A larger batch size means that + model parameters are updated less frequently, but with lower + variance. + oneOf: + - type: string + enum: + - auto + - type: integer + minimum: 1 + maximum: 256 + default: auto + learning_rate_multiplier: + description: > + Scaling factor for the learning rate. A smaller learning rate + may be useful to avoid overfitting. + oneOf: + - type: string + enum: + - auto + - type: number + minimum: 0 + exclusiveMinimum: true + default: auto + n_epochs: + description: > + The number of epochs to train the model for. An epoch refers to + one full cycle through the training dataset. + oneOf: + - type: string + enum: + - auto + - type: integer + minimum: 1 + maximum: 50 + default: auto + FineTuneMethod: + type: object + description: The method used for fine-tuning. + properties: + type: + type: string + description: The type of method. Is either `supervised` or `dpo`. + enum: + - supervised + - dpo + supervised: + type: object + $ref: "#/components/schemas/FineTuneSupervisedMethod" + dpo: + type: object + $ref: "#/components/schemas/FineTuneDPOMethod" + FineTunePreferenceRequestInput: + type: object + description: The per-line training example of a fine-tuning input file for chat + models using the dpo method. + properties: + input: + type: object + properties: + messages: + type: array + minItems: 1 + items: + oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestSystemMessage" + - $ref: "#/components/schemas/ChatCompletionRequestUserMessage" + - $ref: "#/components/schemas/FineTuneChatCompletionRequestAssistantMessage" + - $ref: "#/components/schemas/ChatCompletionRequestToolMessage" + - $ref: "#/components/schemas/ChatCompletionRequestFunctionMessage" + x-oaiExpandable: true + tools: + type: array + description: A list of tools the model may generate JSON inputs for. + items: + $ref: "#/components/schemas/ChatCompletionTool" + parallel_tool_calls: + $ref: "#/components/schemas/ParallelToolCalls" + preferred_completion: + type: array + description: The preferred completion message for the output. + maxItems: 1 + items: + oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestAssistantMessage" + x-oaiExpandable: true + non_preferred_completion: + type: array + description: The non-preferred completion message for the output. + maxItems: 1 + items: + oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestAssistantMessage" + x-oaiExpandable: true + x-oaiMeta: + name: Training format for chat models using the preference method + example: > + { + "input": { + "messages": [ + { "role": "user", "content": "What is the weather in San Francisco?" } + ] + }, + "preferred_completion": [ + { + "role": "assistant", + "content": "The weather in San Francisco is 70 degrees Fahrenheit." + } + ], + "non_preferred_completion": [ + { + "role": "assistant", + "content": "The weather in San Francisco is 21 degrees Celsius." + } + ] + } + FineTuneSupervisedMethod: + type: object + description: Configuration for the supervised fine-tuning method. + properties: + hyperparameters: + type: object + description: The hyperparameters used for the fine-tuning job. + properties: + batch_size: + description: > + Number of examples in each batch. A larger batch size means that + model parameters are updated less frequently, but with lower + variance. + oneOf: + - type: string + enum: + - auto + - type: integer + minimum: 1 + maximum: 256 + default: auto + learning_rate_multiplier: + description: > + Scaling factor for the learning rate. A smaller learning rate + may be useful to avoid overfitting. + oneOf: + - type: string + enum: + - auto + - type: number + minimum: 0 + exclusiveMinimum: true + default: auto + n_epochs: + description: > + The number of epochs to train the model for. An epoch refers to + one full cycle through the training dataset. + oneOf: + - type: string + enum: + - auto + - type: integer + minimum: 1 + maximum: 50 + default: auto FineTuningIntegration: type: object title: Fine-Tuning Job Integration @@ -15252,27 +17631,51 @@ components: running. hyperparameters: type: object - description: The hyperparameters used for the fine-tuning job. See the - [fine-tuning guide](/docs/guides/fine-tuning) for more details. + description: The hyperparameters used for the fine-tuning job. This value will + only be returned when running `supervised` jobs. properties: - n_epochs: + batch_size: + description: > + Number of examples in each batch. A larger batch size means that + model parameters + + are updated less frequently, but with lower variance. oneOf: - type: string enum: - auto - type: integer minimum: 1 - maximum: 50 + maximum: 256 + default: auto + learning_rate_multiplier: + description: > + Scaling factor for the learning rate. A smaller learning rate + may be useful to avoid + + overfitting. + oneOf: + - type: string + enum: + - auto + - type: number + minimum: 0 + exclusiveMinimum: true default: auto - description: >- + n_epochs: + description: > The number of epochs to train the model for. An epoch refers to - one full cycle through the training dataset. + one full cycle - "auto" decides the optimal number of epochs based on the size of - the dataset. If setting the number manually, we support any - number between 1 and 50 epochs. - required: - - n_epochs + through the training dataset. + oneOf: + - type: string + enum: + - auto + - type: integer + minimum: 1 + maximum: 50 + default: auto model: type: string description: The base model that is being fine-tuned. @@ -15337,6 +17740,8 @@ components: description: The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running. + method: + $ref: "#/components/schemas/FineTuneMethod" required: - created_at - error @@ -15378,7 +17783,17 @@ components: "trained_tokens": 5768, "integrations": [], "seed": 0, - "estimated_finish": 0 + "estimated_finish": 0, + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "n_epochs": 4, + "batch_size": 1, + "learning_rate_multiplier": 1.0 + } + } + } } FineTuningJobCheckpoint: type: object @@ -15459,22 +17874,37 @@ components: type: object description: Fine-tuning job event object properties: + object: + type: string + description: The object type, which is always "fine_tuning.job.event". + enum: + - fine_tuning.job.event id: type: string + description: The object identifier. created_at: type: integer + description: The Unix timestamp (in seconds) for when the fine-tuning job was + created. level: type: string + description: The log level of the event. enum: - info - warn - error message: type: string - object: + description: The message of the event. + type: type: string + description: The type of event. enum: - - fine_tuning.job.event + - message + - metrics + data: + type: object + description: The data associated with the event. required: - id - object @@ -15489,7 +17919,9 @@ components: "id": "ftevent-abc123" "created_at": 1677610602, "level": "info", - "message": "Created fine-tuning job" + "message": "Created fine-tuning job", + "data": {}, + "type": "message" } FunctionObject: type: object @@ -15600,6 +18032,22 @@ components: accepted_at: type: integer description: The Unix timestamp (in seconds) of when the invite was accepted. + projects: + type: array + description: The projects that were granted membership upon acceptance of the + invite. + items: + type: object + properties: + id: + type: string + description: Project's public ID + role: + type: string + enum: + - member + - owner + description: Project membership role required: - object - id @@ -15619,7 +18067,13 @@ components: "status": "accepted", "invited_at": 1711471533, "expires_at": 1711471533, - "accepted_at": 1711471533 + "accepted_at": 1711471533, + "projects": [ + { + "id": "project-xyz", + "role": "member" + } + ] } InviteDeleteResponse: type: object @@ -15674,6 +18128,27 @@ components: - reader - owner description: "`owner` or `reader`" + projects: + type: array + description: An array of projects to which membership is granted at the same + time the org invite is accepted. If omitted, the user will be + invited to the default project for compatibility with legacy + behavior. + items: + type: object + properties: + id: + type: string + description: Project's public ID + role: + type: string + enum: + - member + - owner + description: Project membership role + required: + - id + - role required: - email - role @@ -15810,17 +18285,28 @@ components: ListFilesResponse: type: object properties: + object: + type: string + example: list data: type: array items: $ref: "#/components/schemas/OpenAIFile" - object: + first_id: type: string - enum: - - list + example: file-abc123 + last_id: + type: string + example: file-abc456 + has_more: + type: boolean + example: false required: - object - data + - first_id + - last_id + - has_more ListFineTuningJobCheckpointsResponse: type: object properties: @@ -16726,7 +19212,7 @@ components: name: The model object example: | { - "id": "VAR_model_id", + "id": "VAR_chat_model_id", "object": "model", "created": 1686935002, "owned_by": "openai" @@ -16739,8 +19225,8 @@ components: description: > ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your - available models, or see our [Model overview](/docs/models/overview) - for descriptions of them. + available models, or see our [Model overview](/docs/models) for + descriptions of them. anyOf: - type: string name: @@ -17007,10 +19493,52 @@ components: - type ParallelToolCalls: description: Whether to enable [parallel function - calling](/docs/guides/function-calling/parallel-function-calling) during - tool use. + calling](/docs/guides/function-calling#configuring-parallel-function-calling) + during tool use. type: boolean default: true + PredictionContent: + type: object + title: Static Content + description: > + Static predicted output content, such as the content of a text file that + is + + being regenerated. + required: + - type + - content + properties: + type: + type: string + enum: + - content + description: | + The type of the predicted content you want to provide. This type is + currently always `content`. + content: + x-oaiExpandable: true + description: > + The content that should be matched when generating a model response. + + If generated tokens would match this content, the entire model + response + + can be returned much more quickly. + oneOf: + - type: string + title: Text content + description: | + The content used for a Predicted Output. This is often the + text of a file you are regenerating with minor changes. + - type: array + description: An array of content parts with a defined type. Supported options + differ based on the [model](/docs/models) being used to generate + the response. Can contain text inputs. + title: Array of content parts + items: + $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartText" + minItems: 1 Project: type: object description: Represents an individual project. @@ -17188,6 +19716,104 @@ components: - first_id - last_id - has_more + ProjectRateLimit: + type: object + description: Represents a project rate limit config. + properties: + object: + type: string + enum: + - project.rate_limit + description: The object type, which is always `project.rate_limit` + id: + type: string + description: The identifier, which can be referenced in API endpoints. + model: + type: string + description: The model this rate limit applies to. + max_requests_per_1_minute: + type: integer + description: The maximum requests per minute. + max_tokens_per_1_minute: + type: integer + description: The maximum tokens per minute. + max_images_per_1_minute: + type: integer + description: The maximum images per minute. Only present for relevant models. + max_audio_megabytes_per_1_minute: + type: integer + description: The maximum audio megabytes per minute. Only present for relevant + models. + max_requests_per_1_day: + type: integer + description: The maximum requests per day. Only present for relevant models. + batch_1_day_max_input_tokens: + type: integer + description: The maximum batch input tokens per day. Only present for relevant + models. + required: + - object + - id + - model + - max_requests_per_1_minute + - max_tokens_per_1_minute + x-oaiMeta: + name: The project rate limit object + example: | + { + "object": "project.rate_limit", + "id": "rl_ada", + "model": "ada", + "max_requests_per_1_minute": 600, + "max_tokens_per_1_minute": 150000, + "max_images_per_1_minute": 10 + } + ProjectRateLimitListResponse: + type: object + properties: + object: + type: string + enum: + - list + data: + type: array + items: + $ref: "#/components/schemas/ProjectRateLimit" + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + required: + - object + - data + - first_id + - last_id + - has_more + ProjectRateLimitUpdateRequest: + type: object + properties: + max_requests_per_1_minute: + type: integer + description: The maximum requests per minute. + max_tokens_per_1_minute: + type: integer + description: The maximum tokens per minute. + max_images_per_1_minute: + type: integer + description: The maximum images per minute. Only relevant for certain models. + max_audio_megabytes_per_1_minute: + type: integer + description: The maximum audio megabytes per minute. Only relevant for certain + models. + max_requests_per_1_day: + type: integer + description: The maximum requests per day. Only relevant for certain models. + batch_1_day_max_input_tokens: + type: integer + description: The maximum batch input tokens per day. Only relevant for certain + models. ProjectServiceAccount: type: object description: Represents an individual service account in a project. @@ -17443,30 +20069,46 @@ components: - role RealtimeClientEventConversationItemCreate: type: object - description: >- + description: > Add a new Item to the Conversation's context, including messages, - function calls, and function call responses. This event can be used both - to populate a "history" of the conversation and to add new items - mid-stream, but has the current limitation that it cannot populate - assistant audio messages. + function + + calls, and function call responses. This event can be used both to + populate a + + "history" of the conversation and to add new items mid-stream, but has + the + + current limitation that it cannot populate assistant audio messages. + If successful, the server will respond with a - `conversation.item.created` event, otherwise an `error` event will be - sent. + `conversation.item.created` + + event, otherwise an `error` event will be sent. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string + enum: + - conversation.item.create description: The event type, must be `conversation.item.create`. previous_item_id: type: string - description: The ID of the preceding item after which the new item will be - inserted. If not set, the new item will be appended to the end of - the conversation. If set, it allows an item to be inserted - mid-conversation. If the ID cannot be found, an error will be - returned and the item will not be added. + description: > + The ID of the preceding item after which the new item will be + inserted. + + If not set, the new item will be appended to the end of the + conversation. + + If set, it allows an item to be inserted mid-conversation. If the + ID + + cannot be found, an error will be returned and the item will not be + added. item: $ref: "#/components/schemas/RealtimeConversationItem" required: @@ -17494,18 +20136,25 @@ components: } RealtimeClientEventConversationItemDelete: type: object - description: Send this event when you want to remove any item from the - conversation history. The server will respond with a - `conversation.item.deleted` event, unless the item does not exist in the - conversation history, in which case the server will respond with an - error. + description: > + Send this event when you want to remove any item from the conversation + + history. The server will respond with a `conversation.item.deleted` + event, + + unless the item does not exist in the conversation history, in which + case the + + server will respond with an error. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string - description: The event type, must be "conversation.item.delete". + enum: + - conversation.item.delete + description: The event type, must be `conversation.item.delete`. item_id: type: string description: The ID of the item to delete. @@ -17523,37 +20172,61 @@ components: } RealtimeClientEventConversationItemTruncate: type: object - description: >- + description: > Send this event to truncate a previous assistant message’s audio. The - server will produce audio faster than realtime, so this event is useful - when the user interrupts to truncate audio that has already been sent to - the client but not yet played. This will synchronize the server's - understanding of the audio with the client's playback. + server + + will produce audio faster than realtime, so this event is useful when + the user + + interrupts to truncate audio that has already been sent to the client + but not + + yet played. This will synchronize the server's understanding of the + audio with + + the client's playback. + Truncating audio will delete the server-side text transcript to ensure - there is not text in the context that hasn't been heard by the user. + there + + is not text in the context that hasn't been heard by the user. + If successful, the server will respond with a - `conversation.item.truncated` event. + `conversation.item.truncated` + + event. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string - description: The event type, must be "conversation.item.truncate". + enum: + - conversation.item.truncate + description: The event type, must be `conversation.item.truncate`. item_id: type: string - description: The ID of the assistant message item to truncate. Only assistant - message items can be truncated. + description: > + The ID of the assistant message item to truncate. Only assistant + message + + items can be truncated. content_index: type: integer description: The index of the content part to truncate. Set this to 0. audio_end_ms: type: integer - description: Inclusive duration up to which audio is truncated, in milliseconds. - If the audio_end_ms is greater than the actual audio duration, the - server will respond with an error. + description: > + Inclusive duration up to which audio is truncated, in milliseconds. + If + + the audio_end_ms is greater than the actual audio duration, the + server + + will respond with an error. required: - type - item_id @@ -17572,28 +20245,48 @@ components: } RealtimeClientEventInputAudioBufferAppend: type: object - description: >- + description: > Send this event to append audio bytes to the input audio buffer. The - audio buffer is temporary storage you can write to and later commit. In - Server VAD mode, the audio buffer is used to detect speech and the - server will decide when to commit. When Server VAD is disabled, you must - commit the audio buffer manually. + audio + + buffer is temporary storage you can write to and later commit. In Server + VAD + + mode, the audio buffer is used to detect speech and the server will + decide + + when to commit. When Server VAD is disabled, you must commit the audio + buffer + + manually. + The client may choose how much audio to place in each event up to a - maximum of 15 MiB, for example streaming smaller chunks from the client - may allow the VAD to be more responsive. Unlike made other client - events, the server will not send a confirmation response to this event. + maximum + + of 15 MiB, for example streaming smaller chunks from the client may + allow the + + VAD to be more responsive. Unlike made other client events, the server + will + + not send a confirmation response to this event. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string - description: The event type, must be "input_audio_buffer.append". + enum: + - input_audio_buffer.append + description: The event type, must be `input_audio_buffer.append`. audio: type: string - description: Base64-encoded audio bytes. This must be in the format specified by - the `input_audio_format` field in the session configuration. + description: > + Base64-encoded audio bytes. This must be in the format specified by + the + + `input_audio_format` field in the session configuration. required: - type - audio @@ -17608,15 +20301,18 @@ components: } RealtimeClientEventInputAudioBufferClear: type: object - description: Send this event to clear the audio bytes in the buffer. The server - will respond with an `input_audio_buffer.cleared` event. + description: | + Send this event to clear the audio bytes in the buffer. The server will + respond with an `input_audio_buffer.cleared` event. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string - description: The event type, must be "input_audio_buffer.clear". + enum: + - input_audio_buffer.clear + description: The event type, must be `input_audio_buffer.clear`. required: - type x-oaiMeta: @@ -17629,24 +20325,40 @@ components: } RealtimeClientEventInputAudioBufferCommit: type: object - description: >- + description: > Send this event to commit the user input audio buffer, which will create - a new user message item in the conversation. This event will produce an - error if the input audio buffer is empty. When in Server VAD mode, the - client does not need to send this event, the server will commit the - audio buffer automatically. + a + + new user message item in the conversation. This event will produce an + error + + if the input audio buffer is empty. When in Server VAD mode, the client + does + + not need to send this event, the server will commit the audio buffer + + automatically. + + + Committing the input audio buffer will trigger input audio + transcription + + (if enabled in session configuration), but it will not create a + response - Committing the input audio buffer will trigger input audio transcription - (if enabled in session configuration), but it will not create a response from the model. The server will respond with an - `input_audio_buffer.committed` event. + `input_audio_buffer.committed` + + event. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string - description: The event type, must be "input_audio_buffer.commit". + enum: + - input_audio_buffer.commit + description: The event type, must be `input_audio_buffer.commit`. required: - type x-oaiMeta: @@ -17659,16 +20371,28 @@ components: } RealtimeClientEventResponseCancel: type: object - description: Send this event to cancel an in-progress response. The server will - respond with a `response.cancelled` event or an error if there is no - response to cancel. + description: > + Send this event to cancel an in-progress response. The server will + respond + + with a `response.cancelled` event or an error if there is no response + to + + cancel. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string + enum: + - response.cancel description: The event type, must be `response.cancel`. + response_id: + type: string + description: | + A specific response ID to cancel - if not provided, will cancel an + in-progress response in the default conversation. required: - type x-oaiMeta: @@ -17681,34 +20405,52 @@ components: } RealtimeClientEventResponseCreate: type: object - description: >- + description: > This event instructs the server to create a Response, which means - triggering model inference. When in Server VAD mode, the server will - create Responses automatically. + triggering + + model inference. When in Server VAD mode, the server will create + Responses + + automatically. + A Response will include at least one Item, and may have two, in which - case the second will be a function call. These Items will be appended to - the conversation history. + case + + the second will be a function call. These Items will be appended to the + + conversation history. + The server will respond with a `response.created` event, events for - Items and content created, and finally a `response.done` event to - indicate the Response is complete. + Items + + and content created, and finally a `response.done` event to indicate + the + + Response is complete. + + + The `response.create` event includes inference configuration like - The `response.create` event includes inference configuration like `instructions`, and `temperature`. These fields will override the - Session's configuration for this Response only. + Session's + + configuration for this Response only. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string + enum: + - response.create description: The event type, must be `response.create`. response: - $ref: "#/components/schemas/RealtimeResponse" + $ref: "#/components/schemas/RealtimeResponseCreateParams" required: - type - - response x-oaiMeta: name: response.create group: realtime @@ -17719,7 +20461,7 @@ components: "response": { "modalities": ["text", "audio"], "instructions": "Please assist the user.", - "voice": "alloy", + "voice": "sage", "output_audio_format": "pcm16", "tools": [ { @@ -17737,42 +20479,54 @@ components: } ], "tool_choice": "auto", - "temperature": 0.7, - "max_output_tokens": 150 + "temperature": 0.8, + "max_output_tokens": 1024 } } RealtimeClientEventSessionUpdate: type: object - description: Send this event to update the session’s default configuration. The - client may send this event at any time to update the session - configuration, and any field may be updated at any time, except for - "voice". The server will respond with a `session.updated` event that - shows the full effective configuration. Only fields that are present are - updated, thus the correct way to clear a field like "instructions" is to - pass an empty string. + description: > + Send this event to update the session’s default configuration. The + client may + + send this event at any time to update the session configuration, and + any + + field may be updated at any time, except for "voice". The server will + respond + + with a `session.updated` event that shows the full effective + configuration. + + Only fields that are present are updated, thus the correct way to clear + a + + field like "instructions" is to pass an empty string. properties: event_id: type: string description: Optional client-generated ID used to identify this event. type: type: string - description: The event type, must be "session.update". + enum: + - session.update + description: The event type, must be `session.update`. session: - $ref: "#/components/schemas/RealtimeSession" + $ref: "#/components/schemas/RealtimeSessionCreateRequest" required: - type - session x-oaiMeta: name: session.update group: realtime - example: > + example: | { "event_id": "event_123", "type": "session.update", "session": { "modalities": ["text", "audio"], - "instructions": "Your knowledge cutoff is 2023-10. You are a helpful assistant.", - "voice": "alloy", + "instructions": "You are a helpful assistant.", + "voice": "sage", "input_audio_format": "pcm16", "output_audio_format": "pcm16", "input_audio_transcription": { @@ -17782,13 +20536,14 @@ components: "type": "server_vad", "threshold": 0.5, "prefix_padding_ms": 300, - "silence_duration_ms": 500 + "silence_duration_ms": 500, + "create_response": true }, "tools": [ { "type": "function", "name": "get_weather", - "description": "Get the current weather for a location, tell the user you are fetching the weather.", + "description": "Get the current weather...", "parameters": { "type": "object", "properties": { @@ -17805,63 +20560,133 @@ components: } RealtimeConversationItem: type: object + x-oaiExpandable: true description: The item to add to the conversation. properties: id: type: string - description: The unique ID of the item, this can be generated by the client to - help manage server-side context, but is not required because the - server will generate one if not provided. + description: > + The unique ID of the item, this can be generated by the client to + help + + manage server-side context, but is not required because the server + will + + generate one if not provided. type: type: string - description: The type of the item (`message`, `function_call`, + enum: + - message + - function_call + - function_call_output + description: > + The type of the item (`message`, `function_call`, `function_call_output`). + object: + type: string + enum: + - realtime.item + description: > + Identifier for the API object being returned - always + `realtime.item`. status: type: string - description: The status of the item (`completed`, `incomplete`). These have no - effect on the conversation, but are accepted for consistency with - the `conversation.item.created` event. + enum: + - completed + - incomplete + description: > + The status of the item (`completed`, `incomplete`). These have no + effect + + on the conversation, but are accepted for consistency with the + + `conversation.item.created` event. role: type: string - description: The role of the message sender (`user`, `assistant`, `system`), - only applicable for `message` items. + enum: + - user + - assistant + - system + description: > + The role of the message sender (`user`, `assistant`, `system`), + only + + applicable for `message` items. content: type: array - description: The content of the message, applicable for `message` items. Message - items with a role of `system` support only `input_text` content, - message items of role `user` support `input_text` and `input_audio` - content, and message items of role `assistant` support `text` - content. + x-oaiExpandable: true + description: > + The content of the message, applicable for `message` items. + + - Message items of role `system` support only `input_text` content + + - Message items of role `user` support `input_text` and + `input_audio` + content + - Message items of role `assistant` support `text` content. items: type: object + x-oaiExpandable: true properties: type: type: string - description: The content type (`input_text`, `input_audio`, `text`). + enum: + - input_audio + - input_text + - item_reference + - text + description: > + The content type (`input_text`, `input_audio`, + `item_reference`, `text`). text: type: string - description: The text content, used for `input_text` and `text` content types. + description: > + The text content, used for `input_text` and `text` content + types. + id: + type: string + description: > + ID of a previous conversation item to reference (for + `item_reference` + + content types in `response.create` events). These can + reference both + + client and server created items. audio: type: string - description: Base64-encoded audio bytes, used for `input_audio` content type. + description: > + Base64-encoded audio bytes, used for `input_audio` content + type. transcript: type: string - description: The transcript of the audio, used for `input_audio` content type. + description: > + The transcript of the audio, used for `input_audio` content + type. call_id: type: string - description: The ID of the function call (for `function_call` and - `function_call_output` items). If passed on a `function_call_output` + description: > + The ID of the function call (for `function_call` and + + `function_call_output` items). If passed on a + `function_call_output` + item, the server will check that a `function_call` item with the - same ID exists in the conversation history. + same + + ID exists in the conversation history. name: type: string - description: The name of the function being called (for `function_call` items). + description: | + The name of the function being called (for `function_call` items). arguments: type: string - description: The arguments of the function call (for `function_call` items). + description: | + The arguments of the function call (for `function_call` items). output: type: string - description: The output of the function call (for `function_call_output` items). + description: | + The output of the function call (for `function_call_output` items). RealtimeResponse: type: object description: The response resource. @@ -17871,30 +20696,65 @@ components: description: The unique ID of the response. object: type: string + enum: + - realtime.response description: The object type, must be `realtime.response`. status: type: string - description: The final status of the response (`completed`, `cancelled`, - `failed`, `incomplete`). + enum: + - completed + - cancelled + - failed + - incomplete + description: > + The final status of the response (`completed`, `cancelled`, + `failed`, or + + `incomplete`). status_details: type: object description: Additional details about the status. properties: type: type: string - description: The type of error that caused the response to fail, corresponding - with the `status` field (`cancelled`, `incomplete`, `failed`). + enum: + - completed + - cancelled + - failed + - incomplete + description: > + The type of error that caused the response to fail, + corresponding + + with the `status` field (`completed`, `cancelled`, + `incomplete`, + + `failed`). reason: type: string - description: The reason the Response did not complete. For a `cancelled` - Response, one of `turn_detected` (the server VAD detected a new - start of speech) or `client_cancelled` (the client sent a cancel - event). For an `incomplete` Response, one of `max_output_tokens` - or `content_filter` (the server-side safety filter activated and - cut off the response). + enum: + - turn_detected + - client_cancelled + - max_output_tokens + - content_filter + description: > + The reason the Response did not complete. For a `cancelled` + Response, + + one of `turn_detected` (the server VAD detected a new start of + speech) + + or `client_cancelled` (the client sent a cancel event). For an + + `incomplete` Response, one of `max_output_tokens` or + `content_filter` + + (the server-side safety filter activated and cut off the + response). error: type: object - description: A description of the error that caused the response to fail, + description: | + A description of the error that caused the response to fail, populated when the `status` is `failed`. properties: type: @@ -17907,27 +20767,49 @@ components: type: array description: The list of output items generated by the response. items: - type: object - description: An item in the response output. + $ref: "#/components/schemas/RealtimeConversationItem" + metadata: + description: > + Developer-provided string key-value pairs associated with this + response. + type: object + x-oaiTypeLabel: map + nullable: true usage: type: object - description: Usage statistics for the Response, this will correspond to billing. - A Realtime API session will maintain a conversation context and - append new Items to the Conversation, thus output from previous - turns (text and audio tokens) will become the input for later turns. + description: > + Usage statistics for the Response, this will correspond to billing. + A + + Realtime API session will maintain a conversation context and append + new + + Items to the Conversation, thus output from previous turns (text + and + + audio tokens) will become the input for later turns. properties: total_tokens: type: integer - description: The total number of tokens in the Response including input and - output text and audio tokens. + description: > + The total number of tokens in the Response including input and + output + + text and audio tokens. input_tokens: type: integer - description: The number of input tokens used in the Response, including text and + description: > + The number of input tokens used in the Response, including text + and + audio tokens. output_tokens: type: integer - description: The number of output tokens sent in the Response, including text - and audio tokens. + description: > + The number of output tokens sent in the Response, including text + and + + audio tokens. input_token_details: type: object description: Details about the input tokens used in the Response. @@ -17951,17 +20833,196 @@ components: audio_tokens: type: integer description: The number of audio tokens used in the Response. + RealtimeResponseCreateParams: + type: object + description: Create a new Realtime response with these parameters + properties: + modalities: + type: array + description: | + The set of modalities the model can respond with. To disable audio, + set this to ["text"]. + items: + type: string + enum: + - text + - audio + instructions: + type: string + description: > + The default system instructions (i.e. system message) prepended to + model + + calls. This field allows the client to guide the model on desired + + responses. The model can be instructed on response content and + format, + + (e.g. "be extremely succinct", "act friendly", "here are examples of + good + + responses") and on audio behavior (e.g. "talk quickly", "inject + emotion + + into your voice", "laugh frequently"). The instructions are not + guaranteed + + to be followed by the model, but they provide guidance to the model + on the + + desired behavior. + + + Note that the server sets default instructions which will be used if + this + + field is not set and are visible in the `session.created` event at + the + + start of the session. + voice: + type: string + enum: + - alloy + - ash + - ballad + - coral + - echo + - sage + - shimmer + - verse + description: > + The voice the model uses to respond. Voice cannot be changed during + the + + session once the model has responded with audio at least once. + Current + + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + + `shimmer` and `verse`. + output_audio_format: + type: string + enum: + - pcm16 + - g711_ulaw + - g711_alaw + description: > + The format of output audio. Options are `pcm16`, `g711_ulaw`, or + `g711_alaw`. + tools: + type: array + description: Tools (functions) available to the model. + items: + type: object + properties: + type: + type: string + enum: + - function + description: The type of the tool, i.e. `function`. + name: + type: string + description: The name of the function. + description: + type: string + description: > + The description of the function, including guidance on when + and how + + to call it, and guidance about what to tell the user when + calling + + (if anything). + parameters: + type: object + description: Parameters of the function in JSON Schema. + tool_choice: + type: string + description: > + How the model chooses tools. Options are `auto`, `none`, `required`, + or + + specify a function, like `{"type": "function", "function": {"name": + "my_function"}}`. + temperature: + type: number + description: > + Sampling temperature for the model, limited to [0.6, 1.2]. Defaults + to 0.8. + max_response_output_tokens: + oneOf: + - type: integer + - type: string + enum: + - inf + description: | + Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. + conversation: + description: > + Controls which conversation the response is added to. Currently + supports + + `auto` and `none`, with `auto` as the default value. The `auto` + value + + means that the contents of the response will be added to the default + + conversation. Set this to `none` to create an out-of-band response + which + + will not add items to default conversation. + oneOf: + - type: string + - type: string + default: auto + enum: + - auto + - none + metadata: + description: > + Set of 16 key-value pairs that can be attached to an object. This + can be + + useful for storing additional information about the object in a + structured + + format. Keys can be a maximum of 64 characters long and values can + be a + + maximum of 512 characters long. + type: object + x-oaiTypeLabel: map + nullable: true + input: + type: array + description: > + Input items to include in the prompt for the model. Creates a new + context + + for this response, without including the default conversation. Can + include + + references to items from the default conversation. + items: + $ref: "#/components/schemas/RealtimeConversationItem" RealtimeServerEventConversationCreated: type: object - description: Returned when a conversation is created. Emitted right after - session creation. + description: > + Returned when a conversation is created. Emitted right after session + creation. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "conversation.created". + enum: + - conversation.created + description: The event type, must be `conversation.created`. conversation: type: object description: The conversation resource. @@ -17971,7 +21032,7 @@ components: description: The unique ID of the conversation. object: type: string - description: The object type, must be "realtime.conversation". + description: The object type, must be `realtime.conversation`. required: - event_id - type @@ -17990,23 +21051,35 @@ components: } RealtimeServerEventConversationItemCreated: type: object - description: >- + description: > Returned when a conversation item is created. There are several - scenarios that produce this event: - - The server is generating a Response, which if successful will produce either one or two Items, which will be of type `message` (role `assistant`) or type `function_call`. - - The input audio buffer has been committed, either by the client or the server (in `server_vad` mode). The server will take the content of the input audio buffer and add it to a new user message Item. - - The client has sent a `conversation.item.create` event to add a new Item to the Conversation. + scenarios that + + produce this event: + - The server is generating a Response, which if successful will produce + either one or two Items, which will be of type `message` + (role `assistant`) or type `function_call`. + - The input audio buffer has been committed, either by the client or the + server (in `server_vad` mode). The server will take the content of the + input audio buffer and add it to a new user message Item. + - The client has sent a `conversation.item.create` event to add a new Item + to the Conversation. properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - conversation.item.created description: The event type, must be `conversation.item.created`. previous_item_id: type: string - description: The ID of the preceding item in the Conversation context, allows - the client to understand the order of the conversation. + description: > + The ID of the preceding item in the Conversation context, allows + the + + client to understand the order of the conversation. item: $ref: "#/components/schemas/RealtimeConversationItem" required: @@ -18039,16 +21112,22 @@ components: } RealtimeServerEventConversationItemDeleted: type: object - description: Returned when an item in the conversation is deleted by the client - with a `conversation.item.delete` event. This event is used to - synchronize the server's understanding of the conversation history with - the client's view. + description: > + Returned when an item in the conversation is deleted by the client with + a + + `conversation.item.delete` event. This event is used to synchronize the + + server's understanding of the conversation history with the client's + view. properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - conversation.item.deleted description: The event type, must be `conversation.item.deleted`. item_id: type: string @@ -18068,25 +21147,41 @@ components: } RealtimeServerEventConversationItemInputAudioTranscriptionCompleted: type: object - description: >- + description: > This event is the output of audio transcription for user audio written - to the user audio buffer. Transcription begins when the input audio - buffer is committed by the client or server (in `server_vad` mode). - Transcription runs asynchronously with Response creation, so this event - may come before or after the Response events. + to the + + user audio buffer. Transcription begins when the input audio buffer is + + committed by the client or server (in `server_vad` mode). Transcription + runs + + asynchronously with Response creation, so this event may come before or + after + + the Response events. + Realtime API models accept audio natively, and thus input transcription - is a separate process run on a separate ASR (Automatic Speech - Recognition) model, currently always `whisper-1`. Thus the transcript - may diverge somewhat from the model's interpretation, and should be - treated as a rough guide. + is a + + separate process run on a separate ASR (Automatic Speech Recognition) + model, + + currently always `whisper-1`. Thus the transcript may diverge somewhat + from + + the model's interpretation, and should be treated as a rough guide. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be + enum: + - conversation.item.input_audio_transcription.completed + description: | + The event type, must be `conversation.item.input_audio_transcription.completed`. item_id: type: string @@ -18116,17 +21211,23 @@ components: } RealtimeServerEventConversationItemInputAudioTranscriptionFailed: type: object - description: Returned when input audio transcription is configured, and a - transcription request for a user message failed. These events are - separate from other `error` events so that the client can identify the - related Item. + description: > + Returned when input audio transcription is configured, and a + transcription + + request for a user message failed. These events are separate from other + + `error` events so that the client can identify the related Item. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be + enum: + - conversation.item.input_audio_transcription.failed + description: | + The event type, must be `conversation.item.input_audio_transcription.failed`. item_id: type: string @@ -18174,21 +21275,29 @@ components: } RealtimeServerEventConversationItemTruncated: type: object - description: >- + description: > Returned when an earlier assistant audio message item is truncated by - the client with a `conversation.item.truncate` event. This event is used - to synchronize the server's understanding of the audio with the client's + the + + client with a `conversation.item.truncate` event. This event is used to + + synchronize the server's understanding of the audio with the client's playback. + This action will truncate the audio and remove the server-side text - transcript to ensure there is no text in the context that hasn't been - heard by the user. + transcript + + to ensure there is no text in the context that hasn't been heard by the + user. properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - conversation.item.truncated description: The event type, must be `conversation.item.truncated`. item_id: type: string @@ -18198,7 +21307,8 @@ components: description: The index of the content part that was truncated. audio_end_ms: type: integer - description: The duration up to which the audio was truncated, in milliseconds. + description: | + The duration up to which the audio was truncated, in milliseconds. required: - event_id - type @@ -18218,37 +21328,51 @@ components: } RealtimeServerEventError: type: object - description: Returned when an error occurs, which could be a client problem or a - server problem. Most errors are recoverable and the session will stay - open, we recommend to implementors to monitor and log error messages by - default. + description: > + Returned when an error occurs, which could be a client problem or a + server + + problem. Most errors are recoverable and the session will stay open, we + + recommend to implementors to monitor and log error messages by default. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "error". + enum: + - error + description: The event type, must be `error`. error: type: object description: Details of the error. + required: + - type + - message properties: type: type: string - description: The type of error (e.g., "invalid_request_error", "server_error"). + description: > + The type of error (e.g., "invalid_request_error", + "server_error"). code: type: string description: Error code, if any. + nullable: true message: type: string description: A human-readable error message. param: type: string description: Parameter related to the error, if any. + nullable: true event_id: type: string - description: The event_id of the client event that caused the error, if + description: > + The event_id of the client event that caused the error, if applicable. + nullable: true required: - event_id - type @@ -18270,14 +21394,17 @@ components: } RealtimeServerEventInputAudioBufferCleared: type: object - description: Returned when the input audio buffer is cleared by the client with - a `input_audio_buffer.clear` event. + description: | + Returned when the input audio buffer is cleared by the client with a + `input_audio_buffer.clear` event. properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - input_audio_buffer.cleared description: The event type, must be `input_audio_buffer.cleared`. required: - event_id @@ -18292,20 +21419,30 @@ components: } RealtimeServerEventInputAudioBufferCommitted: type: object - description: Returned when an input audio buffer is committed, either by the - client or automatically in server VAD mode. The `item_id` property is - the ID of the user message item that will be created, thus a - `conversation.item.created` event will also be sent to the client. + description: > + Returned when an input audio buffer is committed, either by the client + or + + automatically in server VAD mode. The `item_id` property is the ID of + the user + + message item that will be created, thus a `conversation.item.created` + event + + will also be sent to the client. properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - input_audio_buffer.committed description: The event type, must be `input_audio_buffer.committed`. previous_item_id: type: string - description: The ID of the preceding item after which the new item will be + description: > + The ID of the preceding item after which the new item will be inserted. item_id: type: string @@ -18327,32 +21464,56 @@ components: } RealtimeServerEventInputAudioBufferSpeechStarted: type: object - description: Sent by the server when in `server_vad` mode to indicate that - speech has been detected in the audio buffer. This can happen any time - audio is added to the buffer (unless speech is already detected). The - client may want to use this event to interrupt audio playback or provide - visual feedback to the user. The client should expect to receive a - `input_audio_buffer.speech_stopped` event when speech stops. The - `item_id` property is the ID of the user message item that will be - created when speech stops and will also be included in the + description: > + Sent by the server when in `server_vad` mode to indicate that speech has + been + + detected in the audio buffer. This can happen any time audio is added to + the + + buffer (unless speech is already detected). The client may want to use + this + + event to interrupt audio playback or provide visual feedback to the + user. + + + The client should expect to receive a + `input_audio_buffer.speech_stopped` event + + when speech stops. The `item_id` property is the ID of the user message + item + + that will be created when speech stops and will also be included in the + `input_audio_buffer.speech_stopped` event (unless the client manually - commits the audio buffer during VAD activation). + commits + + the audio buffer during VAD activation). properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - input_audio_buffer.speech_started description: The event type, must be `input_audio_buffer.speech_started`. audio_start_ms: type: integer - description: Milliseconds from the start of all audio written to the buffer - during the session when speech was first detected. This will - correspond to the beginning of audio sent to the model, and thus - includes the `prefix_padding_ms` configured in the Session. + description: > + Milliseconds from the start of all audio written to the buffer + during the + + session when speech was first detected. This will correspond to the + + beginning of audio sent to the model, and thus includes the + + `prefix_padding_ms` configured in the Session. item_id: type: string - description: The ID of the user message item that will be created when speech + description: > + The ID of the user message item that will be created when speech stops. required: - event_id @@ -18371,22 +21532,33 @@ components: } RealtimeServerEventInputAudioBufferSpeechStopped: type: object - description: Returned in `server_vad` mode when the server detects the end of - speech in the audio buffer. The server will also send an - `conversation.item.created` event with the user message item that is - created from the audio buffer. + description: > + Returned in `server_vad` mode when the server detects the end of speech + in + + the audio buffer. The server will also send an + `conversation.item.created` + + event with the user message item that is created from the audio buffer. properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - input_audio_buffer.speech_stopped description: The event type, must be `input_audio_buffer.speech_stopped`. audio_end_ms: type: integer - description: Milliseconds since the session started when speech stopped. This - will correspond to the end of audio sent to the model, and thus - includes the `min_silence_duration_ms` configured in the Session. + description: > + Milliseconds since the session started when speech stopped. This + will + + correspond to the end of audio sent to the model, and thus includes + the + + `min_silence_duration_ms` configured in the Session. item_id: type: string description: The ID of the user message item that will be created. @@ -18407,16 +21579,25 @@ components: } RealtimeServerEventRateLimitsUpdated: type: object - description: Emitted at the beginning of a Response to indicate the updated rate - limits. When a Response is created some tokens will be "reserved" for - the output tokens, the rate limits shown here reflect that reservation, - which is then adjusted accordingly once the Response is completed. + description: > + Emitted at the beginning of a Response to indicate the updated rate + limits. + + When a Response is created some tokens will be "reserved" for the + output + + tokens, the rate limits shown here reflect that reservation, which is + then + + adjusted accordingly once the Response is completed. properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - rate_limits.updated description: The event type, must be `rate_limits.updated`. rate_limits: type: array @@ -18426,7 +21607,11 @@ components: properties: name: type: string - description: The name of the rate limit (`requests`, `tokens`). + enum: + - requests + - tokens + description: | + The name of the rate limit (`requests`, `tokens`). limit: type: integer description: The maximum allowed value for the rate limit. @@ -18471,7 +21656,9 @@ components: description: The unique ID of the server event. type: type: string - description: The event type, must be "response.audio.delta". + enum: + - response.audio.delta + description: The event type, must be `response.audio.delta`. response_id: type: string description: The ID of the response. @@ -18510,15 +21697,20 @@ components: } RealtimeServerEventResponseAudioDone: type: object - description: Returned when the model-generated audio is done. Also emitted when - a Response is interrupted, incomplete, or cancelled. + description: > + Returned when the model-generated audio is done. Also emitted when a + Response + + is interrupted, incomplete, or cancelled. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.audio.done". + enum: + - response.audio.done + description: The event type, must be `response.audio.done`. response_id: type: string description: The ID of the response. @@ -18552,7 +21744,8 @@ components: } RealtimeServerEventResponseAudioTranscriptDelta: type: object - description: Returned when the model-generated transcription of audio output is + description: > + Returned when the model-generated transcription of audio output is updated. properties: event_id: @@ -18560,7 +21753,9 @@ components: description: The unique ID of the server event. type: type: string - description: The event type, must be "response.audio_transcript.delta". + enum: + - response.audio_transcript.delta + description: The event type, must be `response.audio_transcript.delta`. response_id: type: string description: The ID of the response. @@ -18599,16 +21794,19 @@ components: } RealtimeServerEventResponseAudioTranscriptDone: type: object - description: Returned when the model-generated transcription of audio output is - done streaming. Also emitted when a Response is interrupted, incomplete, - or cancelled. + description: | + Returned when the model-generated transcription of audio output is done + streaming. Also emitted when a Response is interrupted, incomplete, or + cancelled. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.audio_transcript.done". + enum: + - response.audio_transcript.done + description: The event type, must be `response.audio_transcript.done`. response_id: type: string description: The ID of the response. @@ -18647,15 +21845,20 @@ components: } RealtimeServerEventResponseContentPartAdded: type: object - description: Returned when a new content part is added to an assistant message - item during response generation. + description: > + Returned when a new content part is added to an assistant message item + during + + response generation. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.content_part.added". + enum: + - response.content_part.added + description: The event type, must be `response.content_part.added`. response_id: type: string description: The ID of the response. @@ -18674,6 +21877,9 @@ components: properties: type: type: string + enum: + - audio + - text description: The content type ("text", "audio"). text: type: string @@ -18710,16 +21916,20 @@ components: } RealtimeServerEventResponseContentPartDone: type: object - description: Returned when a content part is done streaming in an assistant - message item. Also emitted when a Response is interrupted, incomplete, - or cancelled. + description: > + Returned when a content part is done streaming in an assistant message + item. + + Also emitted when a Response is interrupted, incomplete, or cancelled. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.content_part.done". + enum: + - response.content_part.done + description: The event type, must be `response.content_part.done`. response_id: type: string description: The ID of the response. @@ -18738,6 +21948,9 @@ components: properties: type: type: string + enum: + - audio + - text description: The content type ("text", "audio"). text: type: string @@ -18774,15 +21987,19 @@ components: } RealtimeServerEventResponseCreated: type: object - description: Returned when a new Response is created. The first event of - response creation, where the response is in an initial state of - `in_progress`. + description: > + Returned when a new Response is created. The first event of response + creation, + + where the response is in an initial state of `in_progress`. properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - response.created description: The event type, must be `response.created`. response: $ref: "#/components/schemas/RealtimeResponse" @@ -18808,17 +22025,24 @@ components: } RealtimeServerEventResponseDone: type: object - description: Returned when a Response is done streaming. Always emitted, no - matter the final state. The Response object included in the - `response.done` event will include all output Items in the Response but - will omit the raw audio data. + description: > + Returned when a Response is done streaming. Always emitted, no matter + the + + final state. The Response object included in the `response.done` event + will + + include all output Items in the Response but will omit the raw audio + data. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.done". + enum: + - response.done + description: The event type, must be `response.done`. response: $ref: "#/components/schemas/RealtimeResponse" required: @@ -18857,9 +22081,13 @@ components: "input_tokens":127, "output_tokens":148, "input_token_details": { - "cached_tokens":0, + "cached_tokens":384, "text_tokens":119, - "audio_tokens":8 + "audio_tokens":8, + "cached_tokens_details": { + "text_tokens": 128, + "audio_tokens": 256 + } }, "output_token_details": { "text_tokens":36, @@ -18870,14 +22098,18 @@ components: } RealtimeServerEventResponseFunctionCallArgumentsDelta: type: object - description: Returned when the model-generated function call arguments are updated. + description: | + Returned when the model-generated function call arguments are updated. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.function_call_arguments.delta". + enum: + - response.function_call_arguments.delta + description: | + The event type, must be `response.function_call_arguments.delta`. response_id: type: string description: The ID of the response. @@ -18916,16 +22148,21 @@ components: } RealtimeServerEventResponseFunctionCallArgumentsDone: type: object - description: Returned when the model-generated function call arguments are done - streaming. Also emitted when a Response is interrupted, incomplete, or - cancelled. + description: > + Returned when the model-generated function call arguments are done + streaming. + + Also emitted when a Response is interrupted, incomplete, or cancelled. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.function_call_arguments.done". + enum: + - response.function_call_arguments.done + description: | + The event type, must be `response.function_call_arguments.done`. response_id: type: string description: The ID of the response. @@ -18971,6 +22208,8 @@ components: description: The unique ID of the server event. type: type: string + enum: + - response.output_item.added description: The event type, must be `response.output_item.added`. response_id: type: string @@ -19006,14 +22245,19 @@ components: } RealtimeServerEventResponseOutputItemDone: type: object - description: Returned when an Item is done streaming. Also emitted when a - Response is interrupted, incomplete, or cancelled. + description: > + Returned when an Item is done streaming. Also emitted when a Response + is + + interrupted, incomplete, or cancelled. properties: event_id: type: string description: The unique ID of the server event. type: type: string + enum: + - response.output_item.done description: The event type, must be `response.output_item.done`. response_id: type: string @@ -19061,7 +22305,9 @@ components: description: The unique ID of the server event. type: type: string - description: The event type, must be "response.text.delta". + enum: + - response.text.delta + description: The event type, must be `response.text.delta`. response_id: type: string description: The ID of the response. @@ -19100,16 +22346,20 @@ components: } RealtimeServerEventResponseTextDone: type: object - description: Returned when the text value of a "text" content part is done - streaming. Also emitted when a Response is interrupted, incomplete, or - cancelled. + description: > + Returned when the text value of a "text" content part is done streaming. + Also + + emitted when a Response is interrupted, incomplete, or cancelled. properties: event_id: type: string description: The unique ID of the server event. type: type: string - description: The event type, must be "response.text.done". + enum: + - response.text.done + description: The event type, must be `response.text.done`. response_id: type: string description: The ID of the response. @@ -19148,168 +22398,706 @@ components: } RealtimeServerEventSessionCreated: type: object - description: Returned when a Session is created. Emitted automatically when a - new connection is established as the first server event. This event will - contain the default Session configuration. + description: > + Returned when a Session is created. Emitted automatically when a new + + connection is established as the first server event. This event will + contain + + the default Session configuration. + properties: + event_id: + type: string + description: The unique ID of the server event. + type: + type: string + enum: + - session.created + description: The event type, must be `session.created`. + session: + $ref: "#/components/schemas/RealtimeSession" + required: + - event_id + - type + - session + x-oaiMeta: + name: session.created + group: realtime + example: | + { + "event_id": "event_1234", + "type": "session.created", + "session": { + "id": "sess_001", + "object": "realtime.session", + "model": "gpt-4o-realtime-preview-2024-12-17", + "modalities": ["text", "audio"], + "instructions": "...model instructions here...", + "voice": "sage", + "input_audio_format": "pcm16", + "output_audio_format": "pcm16", + "input_audio_transcription": null, + "turn_detection": { + "type": "server_vad", + "threshold": 0.5, + "prefix_padding_ms": 300, + "silence_duration_ms": 200 + }, + "tools": [], + "tool_choice": "auto", + "temperature": 0.8, + "max_response_output_tokens": "inf" + } + } + RealtimeServerEventSessionUpdated: + type: object + description: > + Returned when a session is updated with a `session.update` event, + unless + + there is an error. + properties: + event_id: + type: string + description: The unique ID of the server event. + type: + type: string + enum: + - session.updated + description: The event type, must be `session.updated`. + session: + $ref: "#/components/schemas/RealtimeSession" + required: + - event_id + - type + - session + x-oaiMeta: + name: session.updated + group: realtime + example: | + { + "event_id": "event_5678", + "type": "session.updated", + "session": { + "id": "sess_001", + "object": "realtime.session", + "model": "gpt-4o-realtime-preview-2024-12-17", + "modalities": ["text"], + "instructions": "New instructions", + "voice": "sage", + "input_audio_format": "pcm16", + "output_audio_format": "pcm16", + "input_audio_transcription": { + "model": "whisper-1" + }, + "turn_detection": null, + "tools": [], + "tool_choice": "none", + "temperature": 0.7, + "max_response_output_tokens": 200 + } + } + RealtimeSession: + type: object + description: Realtime session object configuration. + properties: + id: + type: string + description: | + Unique identifier for the session object. + modalities: + description: | + The set of modalities the model can respond with. To disable audio, + set this to ["text"]. + items: + type: string + enum: + - text + - audio + model: + description: | + The Realtime model used for this session. + anyOf: + - type: string + - type: string + enum: + - gpt-4o-realtime-preview + - gpt-4o-realtime-preview-2024-10-01 + - gpt-4o-realtime-preview-2024-12-17 + - gpt-4o-mini-realtime-preview + - gpt-4o-mini-realtime-preview-2024-12-17 + instructions: + type: string + description: > + The default system instructions (i.e. system message) prepended to + model + + calls. This field allows the client to guide the model on desired + + responses. The model can be instructed on response content and + format, + + (e.g. "be extremely succinct", "act friendly", "here are examples of + good + + responses") and on audio behavior (e.g. "talk quickly", "inject + emotion + + into your voice", "laugh frequently"). The instructions are not + guaranteed + + to be followed by the model, but they provide guidance to the model + on the + + desired behavior. + + + Note that the server sets default instructions which will be used if + this + + field is not set and are visible in the `session.created` event at + the + + start of the session. + voice: + type: string + enum: + - alloy + - ash + - ballad + - coral + - echo + - sage + - shimmer + - verse + description: > + The voice the model uses to respond. Voice cannot be changed during + the + + session once the model has responded with audio at least once. + Current + + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + + `shimmer` and `verse`. + input_audio_format: + type: string + enum: + - pcm16 + - g711_ulaw + - g711_alaw + description: > + The format of input audio. Options are `pcm16`, `g711_ulaw`, or + `g711_alaw`. + output_audio_format: + type: string + enum: + - pcm16 + - g711_ulaw + - g711_alaw + description: > + The format of output audio. Options are `pcm16`, `g711_ulaw`, or + `g711_alaw`. + input_audio_transcription: + type: object + description: > + Configuration for input audio transcription, defaults to off and can + be + + set to `null` to turn off once on. Input audio transcription is not + native + + to the model, since the model consumes audio directly. Transcription + runs + + asynchronously through Whisper and should be treated as rough + guidance + + rather than the representation understood by the model. + properties: + model: + type: string + description: > + The model to use for transcription, `whisper-1` is the only + currently + + supported model. + turn_detection: + type: object + nullable: true + description: > + Configuration for turn detection. Can be set to `null` to turn off. + Server + + VAD means that the model will detect the start and end of speech + based on + + audio volume and respond at the end of user speech. + properties: + type: + type: string + enum: + - server_vad + description: > + Type of turn detection, only `server_vad` is currently supported. + threshold: + type: number + description: > + Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. + A + + higher threshold will require louder audio to activate the + model, and + + thus might perform better in noisy environments. + prefix_padding_ms: + type: integer + description: | + Amount of audio to include before the VAD detected speech (in + milliseconds). Defaults to 300ms. + silence_duration_ms: + type: integer + description: > + Duration of silence to detect speech stop (in milliseconds). + Defaults + + to 500ms. With shorter values the model will respond more + quickly, + + but may jump in on short pauses from the user. + tools: + type: array + description: Tools (functions) available to the model. + items: + type: object + properties: + type: + type: string + enum: + - function + description: The type of the tool, i.e. `function`. + name: + type: string + description: The name of the function. + description: + type: string + description: > + The description of the function, including guidance on when + and how + + to call it, and guidance about what to tell the user when + calling + + (if anything). + parameters: + type: object + description: Parameters of the function in JSON Schema. + tool_choice: + type: string + description: > + How the model chooses tools. Options are `auto`, `none`, `required`, + or + + specify a function. + temperature: + type: number + description: > + Sampling temperature for the model, limited to [0.6, 1.2]. Defaults + to 0.8. + max_response_output_tokens: + oneOf: + - type: integer + - type: string + enum: + - inf + description: | + Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. + RealtimeSessionCreateRequest: + type: object + description: Realtime session object configuration. + required: + - model properties: - event_id: + modalities: + description: | + The set of modalities the model can respond with. To disable audio, + set this to ["text"]. + items: + type: string + enum: + - text + - audio + model: type: string - description: The unique ID of the server event. - type: + description: | + The Realtime model used for this session. + enum: + - gpt-4o-realtime-preview + - gpt-4o-realtime-preview-2024-10-01 + - gpt-4o-realtime-preview-2024-12-17 + - gpt-4o-mini-realtime-preview + - gpt-4o-mini-realtime-preview-2024-12-17 + instructions: type: string - description: The event type, must be `session.created`. - session: - $ref: "#/components/schemas/RealtimeSession" - required: - - event_id - - type - - session - x-oaiMeta: - name: session.created - group: realtime - example: | - { - "event_id": "event_1234", - "type": "session.created", - "session": { - "id": "sess_001", - "object": "realtime.session", - "model": "gpt-4o-realtime-preview-2024-10-01", - "modalities": ["text", "audio"], - "instructions": "", - "voice": "alloy", - "input_audio_format": "pcm16", - "output_audio_format": "pcm16", - "input_audio_transcription": null, - "turn_detection": { - "type": "server_vad", - "threshold": 0.5, - "prefix_padding_ms": 300, - "silence_duration_ms": 200 - }, - "tools": [], - "tool_choice": "auto", - "temperature": 0.8, - "max_response_output_tokens": null - } - } - RealtimeServerEventSessionUpdated: - type: object - description: Returned when a session is updated with a `session.update` event, - unless there is an error. - properties: - event_id: + description: > + The default system instructions (i.e. system message) prepended to + model + + calls. This field allows the client to guide the model on desired + + responses. The model can be instructed on response content and + format, + + (e.g. "be extremely succinct", "act friendly", "here are examples of + good + + responses") and on audio behavior (e.g. "talk quickly", "inject + emotion + + into your voice", "laugh frequently"). The instructions are not + guaranteed + + to be followed by the model, but they provide guidance to the model + on the + + desired behavior. + + + Note that the server sets default instructions which will be used if + this + + field is not set and are visible in the `session.created` event at + the + + start of the session. + voice: type: string - description: The unique ID of the server event. - type: + enum: + - alloy + - ash + - ballad + - coral + - echo + - sage + - shimmer + - verse + description: > + The voice the model uses to respond. Voice cannot be changed during + the + + session once the model has responded with audio at least once. + Current + + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + + `shimmer` and `verse`. + input_audio_format: type: string - description: The event type, must be "session.updated". - session: - $ref: "#/components/schemas/RealtimeSession" - required: - - event_id - - type - - session - x-oaiMeta: - name: session.updated - group: realtime - example: | - { - "event_id": "event_5678", - "type": "session.updated", - "session": { - "id": "sess_001", - "object": "realtime.session", - "model": "gpt-4o-realtime-preview-2024-10-01", - "modalities": ["text"], - "instructions": "New instructions", - "voice": "alloy", - "input_audio_format": "pcm16", - "output_audio_format": "pcm16", - "input_audio_transcription": { - "model": "whisper-1" - }, - "turn_detection": null, - "tools": [], - "tool_choice": "none", - "temperature": 0.7, - "max_response_output_tokens": 200 - } - } - RealtimeSession: + enum: + - pcm16 + - g711_ulaw + - g711_alaw + description: > + The format of input audio. Options are `pcm16`, `g711_ulaw`, or + `g711_alaw`. + output_audio_format: + type: string + enum: + - pcm16 + - g711_ulaw + - g711_alaw + description: > + The format of output audio. Options are `pcm16`, `g711_ulaw`, or + `g711_alaw`. + input_audio_transcription: + type: object + description: > + Configuration for input audio transcription, defaults to off and can + be + + set to `null` to turn off once on. Input audio transcription is not + native + + to the model, since the model consumes audio directly. Transcription + runs + + asynchronously through Whisper and should be treated as rough + guidance + + rather than the representation understood by the model. + properties: + model: + type: string + description: > + The model to use for transcription, `whisper-1` is the only + currently + + supported model. + turn_detection: + type: object + description: > + Configuration for turn detection. Can be set to `null` to turn off. + Server + + VAD means that the model will detect the start and end of speech + based on + + audio volume and respond at the end of user speech. + properties: + type: + type: string + description: > + Type of turn detection, only `server_vad` is currently supported. + threshold: + type: number + description: > + Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. + A + + higher threshold will require louder audio to activate the + model, and + + thus might perform better in noisy environments. + prefix_padding_ms: + type: integer + description: | + Amount of audio to include before the VAD detected speech (in + milliseconds). Defaults to 300ms. + silence_duration_ms: + type: integer + description: > + Duration of silence to detect speech stop (in milliseconds). + Defaults + + to 500ms. With shorter values the model will respond more + quickly, + + but may jump in on short pauses from the user. + create_response: + type: boolean + default: true + description: | + Whether or not to automatically generate a response when VAD is + enabled. `true` by default. + tools: + type: array + description: Tools (functions) available to the model. + items: + type: object + properties: + type: + type: string + enum: + - function + description: The type of the tool, i.e. `function`. + name: + type: string + description: The name of the function. + description: + type: string + description: > + The description of the function, including guidance on when + and how + + to call it, and guidance about what to tell the user when + calling + + (if anything). + parameters: + type: object + description: Parameters of the function in JSON Schema. + tool_choice: + type: string + description: > + How the model chooses tools. Options are `auto`, `none`, `required`, + or + + specify a function. + temperature: + type: number + description: > + Sampling temperature for the model, limited to [0.6, 1.2]. Defaults + to 0.8. + max_response_output_tokens: + oneOf: + - type: integer + - type: string + enum: + - inf + description: | + Maximum number of output tokens for a single assistant response, + inclusive of tool calls. Provide an integer between 1 and 4096 to + limit output tokens, or `inf` for the maximum available tokens for a + given model. Defaults to `inf`. + RealtimeSessionCreateResponse: type: object - description: Realtime session object configuration. + description: > + A new Realtime session configuration, with an ephermeral key. Default + TTL + + for keys is one minute. properties: + client_secret: + type: object + description: Ephemeral key returned by the API. + properties: + value: + type: string + description: > + Ephemeral key usable in client environments to authenticate + connections + + to the Realtime API. Use this in client-side environments rather + than + + a standard API token, which should only be used server-side. + expires_at: + type: integer + description: > + Timestamp for when the token expires. Currently, all tokens + expire + + after one minute. modalities: - type: array + description: | + The set of modalities the model can respond with. To disable audio, + set this to ["text"]. items: type: string - description: The set of modalities the model can respond with. To disable audio, - set this to ["text"]. + enum: + - text + - audio instructions: type: string - description: >- + description: > The default system instructions (i.e. system message) prepended to - model calls. This field allows the client to guide the model on - desired responses. The model can be instructed on response content - and format, (e.g. "be extremely succinct", "act friendly", "here are - examples of good responses") and on audio behavior (e.g. "talk - quickly", "inject emotion into your voice", "laugh frequently"). The - instructions are not guaranteed to be followed by the model, but - they provide guidance to the model on the desired behavior. + model + + calls. This field allows the client to guide the model on desired + + responses. The model can be instructed on response content and + format, + + (e.g. "be extremely succinct", "act friendly", "here are examples of + good + + responses") and on audio behavior (e.g. "talk quickly", "inject + emotion + + into your voice", "laugh frequently"). The instructions are not + guaranteed + + to be followed by the model, but they provide guidance to the model + on the + + desired behavior. + Note that the server sets default instructions which will be used if - this field is not set and are visible in the `session.created` event - at the start of the session. + this + + field is not set and are visible in the `session.created` event at + the + + start of the session. voice: type: string - description: The voice the model uses to respond - one of `alloy`, `echo`, - or `shimmer`. Cannot be changed once the model has responded with - audio at least once. + enum: + - alloy + - ash + - ballad + - coral + - echo + - sage + - shimmer + - verse + description: > + The voice the model uses to respond. Voice cannot be changed during + the + + session once the model has responded with audio at least once. + Current + + voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + + `shimmer` and `verse`. input_audio_format: type: string - description: The format of input audio. Options are `pcm16`, `g711_ulaw`, or + description: > + The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. output_audio_format: type: string - description: The format of output audio. Options are `pcm16`, `g711_ulaw`, or + description: > + The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. input_audio_transcription: type: object - description: Configuration for input audio transcription, defaults to off and - can be set to `null` to turn off once on. Input audio transcription - is not native to the model, since the model consumes audio directly. - Transcription runs asynchronously through Whisper and should be - treated as rough guidance rather than the representation understood - by the model. + description: > + Configuration for input audio transcription, defaults to off and can + be + + set to `null` to turn off once on. Input audio transcription is not + native + + to the model, since the model consumes audio directly. Transcription + runs + + asynchronously through Whisper and should be treated as rough + guidance + + rather than the representation understood by the model. properties: model: type: string - description: The model to use for transcription, `whisper-1` is the only - currently supported model. + description: > + The model to use for transcription, `whisper-1` is the only + currently + + supported model. turn_detection: type: object - description: Configuration for turn detection. Can be set to `null` to turn off. - Server VAD means that the model will detect the start and end of - speech based on audio volume and respond at the end of user speech. + description: > + Configuration for turn detection. Can be set to `null` to turn off. + Server + + VAD means that the model will detect the start and end of speech + based on + + audio volume and respond at the end of user speech. properties: type: type: string - description: Type of turn detection, only `server_vad` is currently supported. + description: > + Type of turn detection, only `server_vad` is currently supported. threshold: type: number - description: Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A + description: > + Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. + A + higher threshold will require louder audio to activate the - model, and thus might perform better in noisy environments. + model, and + + thus might perform better in noisy environments. prefix_padding_ms: type: integer - description: Amount of audio to include before the VAD detected speech (in + description: | + Amount of audio to include before the VAD detected speech (in milliseconds). Defaults to 300ms. silence_duration_ms: type: integer - description: Duration of silence to detect speech stop (in milliseconds). - Defaults to 500ms. With shorter values the model will respond - more quickly, but may jump in on short pauses from the user. + description: > + Duration of silence to detect speech stop (in milliseconds). + Defaults + + to 500ms. With shorter values the model will respond more + quickly, + + but may jump in on short pauses from the user. tools: type: array description: Tools (functions) available to the model. @@ -19318,25 +23106,36 @@ components: properties: type: type: string + enum: + - function description: The type of the tool, i.e. `function`. name: type: string description: The name of the function. description: type: string - description: The description of the function, including guidance on when and how + description: > + The description of the function, including guidance on when + and how + to call it, and guidance about what to tell the user when - calling (if anything). + calling + + (if anything). parameters: type: object description: Parameters of the function in JSON Schema. tool_choice: type: string - description: How the model chooses tools. Options are `auto`, `none`, - `required`, or specify a function. + description: > + How the model chooses tools. Options are `auto`, `none`, `required`, + or + + specify a function. temperature: type: number - description: Sampling temperature for the model, limited to [0.6, 1.2]. Defaults + description: > + Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. max_response_output_tokens: oneOf: @@ -19344,10 +23143,37 @@ components: - type: string enum: - inf - description: Maximum number of output tokens for a single assistant response, + description: | + Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or `inf` for the maximum available tokens for a given model. Defaults to `inf`. + x-oaiMeta: + name: The session object + group: realtime + example: | + { + "id": "sess_001", + "object": "realtime.session", + "model": "gpt-4o-realtime-preview-2024-12-17", + "modalities": ["audio", "text"], + "instructions": "You are a friendly assistant.", + "voice": "alloy", + "input_audio_format": "pcm16", + "output_audio_format": "pcm16", + "input_audio_transcription": { + "model": "whisper-1" + }, + "turn_detection": null, + "tools": [], + "tool_choice": "none", + "temperature": 0.7, + "max_response_output_tokens": 200, + "client_secret": { + "value": "ek_abc123", + "expires_at": 1234567890 + } + } ResponseFormatJsonObject: type: object properties: @@ -20851,161 +24677,608 @@ components: format: float description: End time of the word in seconds. required: - - word - - start - - end - TruncationObject: + - word + - start + - end + TruncationObject: + type: object + title: Thread Truncation Controls + description: Controls for how a thread will be truncated prior to the run. Use + this to control the intial context window of the run. + properties: + type: + type: string + description: The truncation strategy to use for the thread. The default is + `auto`. If set to `last_messages`, the thread will be truncated to + the n most recent messages in the thread. When set to `auto`, + messages in the middle of the thread will be dropped to fit the + context length of the model, `max_prompt_tokens`. + enum: + - auto + - last_messages + last_messages: + type: integer + description: The number of most recent messages from the thread when + constructing the context for the run. + minimum: 1 + nullable: true + required: + - type + UpdateVectorStoreRequest: + type: object + additionalProperties: false + properties: + name: + description: The name of the vector store. + type: string + nullable: true + expires_after: + $ref: "#/components/schemas/VectorStoreExpirationAfter" + nullable: true + metadata: + description: > + Set of 16 key-value pairs that can be attached to an object. This + can be useful for storing additional information about the object in + a structured format. Keys can be a maximum of 64 characters long and + values can be a maximum of 512 characters long. + type: object + x-oaiTypeLabel: map + nullable: true + Upload: + type: object + title: Upload + description: | + The Upload object can accept byte chunks in the form of Parts. + properties: + id: + type: string + description: The Upload unique identifier, which can be referenced in API + endpoints. + created_at: + type: integer + description: The Unix timestamp (in seconds) for when the Upload was created. + filename: + type: string + description: The name of the file to be uploaded. + bytes: + type: integer + description: The intended number of bytes to be uploaded. + purpose: + type: string + description: The intended purpose of the file. [Please refer + here](/docs/api-reference/files/object#files/object-purpose) for + acceptable values. + status: + type: string + description: The status of the Upload. + enum: + - pending + - completed + - cancelled + - expired + expires_at: + type: integer + description: The Unix timestamp (in seconds) for when the Upload was created. + object: + type: string + description: The object type, which is always "upload". + enum: + - upload + file: + $ref: "#/components/schemas/OpenAIFile" + nullable: true + description: The ready File object after the Upload is completed. + required: + - bytes + - created_at + - expires_at + - filename + - id + - purpose + - status + x-oaiMeta: + name: The upload object + example: | + { + "id": "upload_abc123", + "object": "upload", + "bytes": 2147483648, + "created_at": 1719184911, + "filename": "training_examples.jsonl", + "purpose": "fine-tune", + "status": "completed", + "expires_at": 1719127296, + "file": { + "id": "file-xyz321", + "object": "file", + "bytes": 2147483648, + "created_at": 1719186911, + "filename": "training_examples.jsonl", + "purpose": "fine-tune", + } + } + UploadPart: + type: object + title: UploadPart + description: > + The upload Part represents a chunk of bytes we can add to an Upload + object. + properties: + id: + type: string + description: The upload Part unique identifier, which can be referenced in API + endpoints. + created_at: + type: integer + description: The Unix timestamp (in seconds) for when the Part was created. + upload_id: + type: string + description: The ID of the Upload object that this Part was added to. + object: + type: string + description: The object type, which is always `upload.part`. + enum: + - upload.part + required: + - created_at + - id + - object + - upload_id + x-oaiMeta: + name: The upload part object + example: | + { + "id": "part_def456", + "object": "upload.part", + "created_at": 1719186911, + "upload_id": "upload_abc123" + } + UsageAudioSpeechesResult: + type: object + description: The aggregated audio speeches usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.audio_speeches.result + characters: + type: integer + description: The number of characters processed. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of + the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the + grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of + the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the + grouped usage result. + required: + - object + - characters + - num_model_requests + x-oaiMeta: + name: Audio speeches usage object + example: | + { + "object": "organization.usage.audio_speeches.result", + "characters": 45, + "num_model_requests": 1, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "tts-1" + } + UsageAudioTranscriptionsResult: + type: object + description: The aggregated audio transcriptions usage details of the specific + time bucket. + properties: + object: + type: string + enum: + - organization.usage.audio_transcriptions.result + seconds: + type: integer + description: The number of seconds processed. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of + the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the + grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of + the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the + grouped usage result. + required: + - object + - seconds + - num_model_requests + x-oaiMeta: + name: Audio transcriptions usage object + example: | + { + "object": "organization.usage.audio_transcriptions.result", + "seconds": 10, + "num_model_requests": 1, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "tts-1" + } + UsageCodeInterpreterSessionsResult: + type: object + description: The aggregated code interpreter sessions usage details of the + specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.code_interpreter_sessions.result + sessions: + type: integer + description: The number of code interpreter sessions. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of + the grouped usage result. + required: + - object + - sessions + x-oaiMeta: + name: Code interpreter sessions usage object + example: | + { + "object": "organization.usage.code_interpreter_sessions.result", + "sessions": 1, + "project_id": "proj_abc" + } + UsageCompletionsResult: + type: object + description: The aggregated completions usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.completions.result + input_tokens: + type: integer + description: The aggregated number of text input tokens used, including cached + tokens. For customers subscribe to scale tier, this includes scale + tier tokens. + input_cached_tokens: + type: integer + description: The aggregated number of text input tokens that has been cached + from previous requests. For customers subscribe to scale tier, this + includes scale tier tokens. + output_tokens: + type: integer + description: The aggregated number of text output tokens used. For customers + subscribe to scale tier, this includes scale tier tokens. + input_audio_tokens: + type: integer + description: The aggregated number of audio input tokens used, including cached + tokens. + output_audio_tokens: + type: integer + description: The aggregated number of audio output tokens used. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of + the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the + grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of + the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the + grouped usage result. + batch: + type: boolean + nullable: true + description: When `group_by=batch`, this field tells whether the grouped usage + result is batch or not. + required: + - object + - input_tokens + - output_tokens + - num_model_requests + x-oaiMeta: + name: Completions usage object + example: | + { + "object": "organization.usage.completions.result", + "input_tokens": 5000, + "output_tokens": 1000, + "input_cached_tokens": 4000, + "input_audio_tokens": 300, + "output_audio_tokens": 200, + "num_model_requests": 5, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "gpt-4o-mini-2024-07-18", + "batch": false + } + UsageEmbeddingsResult: type: object - title: Thread Truncation Controls - description: Controls for how a thread will be truncated prior to the run. Use - this to control the intial context window of the run. + description: The aggregated embeddings usage details of the specific time bucket. properties: - type: + object: type: string - description: The truncation strategy to use for the thread. The default is - `auto`. If set to `last_messages`, the thread will be truncated to - the n most recent messages in the thread. When set to `auto`, - messages in the middle of the thread will be dropped to fit the - context length of the model, `max_prompt_tokens`. enum: - - auto - - last_messages - last_messages: + - organization.usage.embeddings.result + input_tokens: type: integer - description: The number of most recent messages from the thread when - constructing the context for the run. - minimum: 1 + description: The aggregated number of input tokens used. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of + the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the + grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of + the grouped usage result. + model: + type: string nullable: true + description: When `group_by=model`, this field provides the model name of the + grouped usage result. required: - - type - UpdateVectorStoreRequest: + - object + - input_tokens + - num_model_requests + x-oaiMeta: + name: Embeddings usage object + example: | + { + "object": "organization.usage.embeddings.result", + "input_tokens": 20, + "num_model_requests": 2, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "text-embedding-ada-002-v2" + } + UsageImagesResult: type: object - additionalProperties: false + description: The aggregated images usage details of the specific time bucket. properties: - name: - description: The name of the vector store. + object: + type: string + enum: + - organization.usage.images.result + images: + type: integer + description: The number of images processed. + num_model_requests: + type: integer + description: The count of requests made to the model. + source: type: string nullable: true - expires_after: - $ref: "#/components/schemas/VectorStoreExpirationAfter" + description: When `group_by=source`, this field provides the source of the + grouped usage result, possible values are `image.generation`, + `image.edit`, `image.variation`. + size: + type: string nullable: true - metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map + description: When `group_by=size`, this field provides the image size of the + grouped usage result. + project_id: + type: string nullable: true - Upload: + description: When `group_by=project_id`, this field provides the project ID of + the grouped usage result. + user_id: + type: string + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the + grouped usage result. + api_key_id: + type: string + nullable: true + description: When `group_by=api_key_id`, this field provides the API key ID of + the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the + grouped usage result. + required: + - object + - images + - num_model_requests + x-oaiMeta: + name: Images usage object + example: | + { + "object": "organization.usage.images.result", + "images": 2, + "num_model_requests": 2, + "size": "1024x1024", + "source": "image.generation", + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "dall-e-3" + } + UsageModerationsResult: type: object - title: Upload - description: | - The Upload object can accept byte chunks in the form of Parts. + description: The aggregated moderations usage details of the specific time bucket. properties: - id: + object: type: string - description: The Upload unique identifier, which can be referenced in API - endpoints. - created_at: + enum: + - organization.usage.moderations.result + input_tokens: type: integer - description: The Unix timestamp (in seconds) for when the Upload was created. - filename: - type: string - description: The name of the file to be uploaded. - bytes: + description: The aggregated number of input tokens used. + num_model_requests: type: integer - description: The intended number of bytes to be uploaded. - purpose: + description: The count of requests made to the model. + project_id: type: string - description: The intended purpose of the file. [Please refer - here](/docs/api-reference/files/object#files/object-purpose) for - acceptable values. - status: + nullable: true + description: When `group_by=project_id`, this field provides the project ID of + the grouped usage result. + user_id: type: string - description: The status of the Upload. - enum: - - pending - - completed - - cancelled - - expired - expires_at: - type: integer - description: The Unix timestamp (in seconds) for when the Upload was created. - object: + nullable: true + description: When `group_by=user_id`, this field provides the user ID of the + grouped usage result. + api_key_id: type: string - description: The object type, which is always "upload". - enum: - - upload - file: - $ref: "#/components/schemas/OpenAIFile" nullable: true - description: The ready File object after the Upload is completed. + description: When `group_by=api_key_id`, this field provides the API key ID of + the grouped usage result. + model: + type: string + nullable: true + description: When `group_by=model`, this field provides the model name of the + grouped usage result. required: - - bytes - - created_at - - expires_at - - filename - - id - - purpose - - status + - object + - input_tokens + - num_model_requests x-oaiMeta: - name: The upload object + name: Moderations usage object example: | { - "id": "upload_abc123", - "object": "upload", - "bytes": 2147483648, - "created_at": 1719184911, - "filename": "training_examples.jsonl", - "purpose": "fine-tune", - "status": "completed", - "expires_at": 1719127296, - "file": { - "id": "file-xyz321", - "object": "file", - "bytes": 2147483648, - "created_at": 1719186911, - "filename": "training_examples.jsonl", - "purpose": "fine-tune", - } + "object": "organization.usage.moderations.result", + "input_tokens": 20, + "num_model_requests": 2, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "text-moderation" } - UploadPart: + UsageResponse: type: object - title: UploadPart - description: > - The upload Part represents a chunk of bytes we can add to an Upload - object. properties: - id: + object: type: string - description: The upload Part unique identifier, which can be referenced in API - endpoints. - created_at: - type: integer - description: The Unix timestamp (in seconds) for when the Part was created. - upload_id: + enum: + - page + data: + type: array + items: + $ref: "#/components/schemas/UsageTimeBucket" + has_more: + type: boolean + next_page: type: string - description: The ID of the Upload object that this Part was added to. + required: + - object + - data + - has_more + - next_page + UsageTimeBucket: + type: object + properties: object: type: string - description: The object type, which is always `upload.part`. enum: - - upload.part + - bucket + start_time: + type: integer + end_time: + type: integer + result: + type: array + items: + oneOf: + - $ref: "#/components/schemas/UsageCompletionsResult" + - $ref: "#/components/schemas/UsageEmbeddingsResult" + - $ref: "#/components/schemas/UsageModerationsResult" + - $ref: "#/components/schemas/UsageImagesResult" + - $ref: "#/components/schemas/UsageAudioSpeechesResult" + - $ref: "#/components/schemas/UsageAudioTranscriptionsResult" + - $ref: "#/components/schemas/UsageVectorStoresResult" + - $ref: "#/components/schemas/UsageCodeInterpreterSessionsResult" + - $ref: "#/components/schemas/CostsResult" required: - - created_at - - id - object - - upload_id + - start_time + - end_time + - result + UsageVectorStoresResult: + type: object + description: The aggregated vector stores usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.vector_stores.result + usage_bytes: + type: integer + description: The vector stores usage in bytes. + project_id: + type: string + nullable: true + description: When `group_by=project_id`, this field provides the project ID of + the grouped usage result. + required: + - object + - usage_bytes x-oaiMeta: - name: The upload part object + name: Vector stores usage object example: | { - "id": "part_def456", - "object": "upload.part", - "created_at": 1719186911, - "upload_id": "upload_abc123" + "object": "organization.usage.vector_stores.result", + "usage_bytes": 1024, + "project_id": "proj_abc" } User: type: object @@ -21506,10 +25779,13 @@ x-oaiMeta: key: cancelFineTuningJob path: cancel - type: object - key: FinetuneChatRequestInput + key: FineTuneChatRequestInput path: chat-input - type: object - key: FinetuneCompletionRequestInput + key: FineTunePreferenceRequestInput + path: preference-input + - type: object + key: FineTuneCompletionRequestInput path: completions-input - type: object key: FineTuningJob @@ -21898,22 +26174,50 @@ x-oaiMeta: - id: administration title: Administration description: > - Programmatically manage your organization. + Programmatically manage your organization. - The Audit Logs endpoint provides a log of all actions taken in - the organization for security and monitoring purposes. + The Audit Logs endpoint provides a log of all actions taken in the + organization for security and monitoring purposes. To access these endpoints please generate an Admin API Key through the [API Platform Organization overview](/organization/admin-keys). Admin API keys cannot be used for non-administration endpoints. For best practices on setting up your organization, please refer to this - [guide](/docs/guides/production-best-practices/setting-up-your-organization) + [guide](/docs/guides/production-best-practices#setting-up-your-organization) + navigationGroup: administration + - id: admin-api-keys + title: Admin API Keys + description: > + The **Usage API** provides detailed insights into your activity across + the OpenAI API. It also includes a separate [Costs + endpoint](/docs/api-reference/usage/costs), which offers visibility into + your spend, breaking down consumption by invoice line items and project + IDs. + + While the Usage API delivers granular usage data, it may not always + reconcile perfectly with the Costs due to minor differences in how usage + and spend are recorded. For financial purposes, we recommend using the + [Costs endpoint](/docs/api-reference/usage/costs) or the [Costs + tab](/settings/organization/usage) in the Usage Dashboard, which will + reconcile back to your billing invoice. navigationGroup: administration + sections: + - type: endpoint + key: admin-api-keys-list + path: list + - type: endpoint + key: admin-api-keys-create + path: create + - type: endpoint + key: admin-api-keys-get + path: listget + - type: endpoint + key: admin-api-keys-delete + path: delete - id: invite title: Invites - description: Invite and manage invitations for an organization. Invited users - are automatically added to the Default project. + description: Invite and manage invitations for an organization. navigationGroup: administration sections: - type: endpoint @@ -21933,9 +26237,8 @@ x-oaiMeta: path: object - id: users title: Users - description: > - Manage users and their role in an organization. Users will be - automatically added to the Default project. + description: | + Manage users and their role in an organization. navigationGroup: administration sections: - type: endpoint @@ -21957,9 +26260,9 @@ x-oaiMeta: title: Projects description: > Manage the projects within an orgnanization includes creation, updating, - and archiving or projects. + and archiving or projects. - The Default project cannot be modified or archived. + The Default project cannot be archived. navigationGroup: administration sections: - type: endpoint @@ -21984,10 +26287,7 @@ x-oaiMeta: title: Project users description: > Manage users within a project, including adding, updating roles, and - removing users. - - Users cannot be removed from the Default project, unless they are being - removed from the organization. + removing users. navigationGroup: administration sections: - type: endpoint @@ -22012,10 +26312,10 @@ x-oaiMeta: title: Project service accounts description: > Manage service accounts within a project. A service account is a bot - user that is not associated with a user. + user that is not associated with a user. If a user leaves an organization, their keys and membership in projects - will no longer work. Service accounts + will no longer work. Service accounts do not have this limitation. However, service accounts can also be deleted from a project. @@ -22040,7 +26340,7 @@ x-oaiMeta: title: Project API keys description: > Manage API keys for a given project. Supports listing and deleting keys - for users. + for users. This API does not allow issuing keys for users, as users need to authorize themselves to generate keys. @@ -22058,14 +26358,29 @@ x-oaiMeta: - type: object key: ProjectApiKey path: object + - id: project-rate-limits + title: Project rate limits + description: > + Manage rate limits per model for projects. Rate limits may be configured + to be equal to or lower than the organization's rate limits. + navigationGroup: administration + sections: + - type: endpoint + key: list-project-rate-limits + path: list + - type: endpoint + key: update-project-rate-limits + path: update + - type: object + key: ProjectRateLimit + path: object - id: audit-logs title: Audit logs description: > - Logs of user actions and configuration changes within this - organization. + Logs of user actions and configuration changes within this organization. To log events, you must activate logging in the [Organization - Settings](/settings/organization/general). + Settings](/settings/organization/general). Once activated, for security reasons, logging cannot be deactivated. navigationGroup: administration @@ -22076,17 +26391,102 @@ x-oaiMeta: - type: object key: AuditLog path: object + - id: usage + title: Usage + description: > + The **Usage API** provides detailed insights into your activity across + the OpenAI API. It also includes a separate [Costs + endpoint](/docs/api-reference/usage/costs), which offers visibility into + your spend, breaking down consumption by invoice line items and project + IDs. + + + While the Usage API delivers granular usage data, it may not always + reconcile perfectly with the Costs due to minor differences in how usage + and spend are recorded. For financial purposes, we recommend using the + [Costs endpoint](/docs/api-reference/usage/costs) or the [Costs + tab](/settings/organization/usage) in the Usage Dashboard, which will + reconcile back to your billing invoice. + navigationGroup: administration + sections: + - type: endpoint + key: usage-completions + path: completions + - type: object + key: UsageCompletionsResult + path: completions_object + - type: endpoint + key: usage-embeddings + path: embeddings + - type: object + key: UsageEmbeddingsResult + path: embeddings_object + - type: endpoint + key: usage-moderations + path: moderations + - type: object + key: UsageModerationsResult + path: moderations_object + - type: endpoint + key: usage-images + path: images + - type: object + key: UsageImagesResult + path: images_object + - type: endpoint + key: usage-audio-speeches + path: audio_speeches + - type: object + key: UsageAudioSpeechesResult + path: audio_speeches_object + - type: endpoint + key: usage-audio-transcriptions + path: audio_transcriptions + - type: object + key: UsageAudioTranscriptionsResult + path: audio_transcriptions_object + - type: endpoint + key: usage-vector-stores + path: vector_stores + - type: object + key: UsageVectorStoresResult + path: vector_stores_object + - type: endpoint + key: usage-code-interpreter-sessions + path: code_interpreter_sessions + - type: object + key: UsageCodeInterpreterSessionsResult + path: code_interpreter_sessions_object + - type: endpoint + key: usage-costs + path: costs + - type: object + key: CostsResult + path: costs_object - id: realtime title: Realtime beta: true + description: | + Communicate with a GPT-4o class model in real time using WebRTC or + WebSockets. Supports text and audio inputs and ouputs, along with audio + transcriptions. + [Learn more about the Realtime API](/docs/guides/realtime). + navigationGroup: realtime + - id: realtime-sessions + title: Session tokens description: > - Communicate with a GPT-4o class model live, in real time, over - WebSocket. + REST API endpoint to generate ephemeral session tokens for use in + client-side - Produces both audio and text transcriptions. - - [Learn more about the Realtime API](/docs/guides/realtime). + applications. navigationGroup: realtime + sections: + - type: endpoint + key: create-realtime-session + path: create + - type: object + key: RealtimeSessionCreateResponse + path: session_object - id: realtime-client-events title: Client events description: > @@ -22220,7 +26620,7 @@ x-oaiMeta: Given a prompt, the model will return one or more predicted completions along with the probabilities of alternative tokens at each position. Most developer should use our [Chat Completions - API](/docs/guides/text-generation/text-generation-models) to leverage + API](/docs/guides/text-generation#text-generation-models) to leverage our best and newest models. sections: - type: endpoint From 3670e3df3b1798eaac65af59a79c09636f883b11 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 16 Jan 2025 16:22:26 -0800 Subject: [PATCH 09/44] expose and test a distinct 'update' type for streamed response audio --- .dotnet/api/OpenAI.netstandard2.0.cs | 13 ++- .../examples/Chat/Example09_ChatWithAudio.cs | 2 +- .../Chat/Example10_ChatWithAudioAsync.cs | 2 +- .../Custom/Chat/Internal/GeneratorStubs.cs | 3 - ...ternalChatCompletionStreamResponseDelta.cs | 5 -- .../src/Custom/Chat/OpenAIChatModelFactory.cs | 26 +++++- .../StreamingChatCompletionUpdate.cs | 2 +- .../StreamingChatResponseAudioUpdate.cs | 28 ++++++ ...letionStreamResponseDelta.Serialization.cs | 32 +++---- ...ternalChatCompletionStreamResponseDelta.cs | 6 +- ...gChatResponseAudioUpdate.Serialization.cs} | 90 +++++++++---------- ...cs => StreamingChatResponseAudioUpdate.cs} | 14 ++- .dotnet/src/Generated/OpenAIModelFactory.cs | 6 ++ .dotnet/tests/Chat/ChatTests.cs | 20 ++++- .scripts/Edit-Serialization.ps1 | 4 +- 15 files changed, 161 insertions(+), 92 deletions(-) create mode 100644 .dotnet/src/Custom/Chat/Streaming/StreamingChatResponseAudioUpdate.cs rename .dotnet/src/Generated/Models/{InternalChatCompletionMessageAudioChunk.Serialization.cs => StreamingChatResponseAudioUpdate.Serialization.cs} (55%) rename .dotnet/src/Generated/Models/{InternalChatCompletionMessageAudioChunk.cs => StreamingChatResponseAudioUpdate.cs} (59%) diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 8ed7eb820..b9feef437 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1487,9 +1487,10 @@ public static class OpenAIChatModelFactory { public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null); public static ChatTokenTopLogProbabilityDetails ChatTokenTopLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null); public static ChatTokenUsage ChatTokenUsage(int outputTokenCount = 0, int inputTokenCount = 0, int totalTokenCount = 0, ChatOutputTokenUsageDetails outputTokenDetails = null, ChatInputTokenUsageDetails inputTokenDetails = null); - public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string completionId = null, ChatMessageContent contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatResponseAudio responseAudio = null); + public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string completionId = null, ChatMessageContent contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, StreamingChatResponseAudioUpdate responseAudioUpdate = null); [Obsolete("This class is obsolete. Please use StreamingChatToolCallUpdate instead.")] public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionName = null, BinaryData functionArgumentsUpdate = null); + public static StreamingChatResponseAudioUpdate StreamingChatResponseAudioUpdate(string id = null, DateTimeOffset? expiresAt = null, string transcriptUpdate = null, BinaryData dataUpdate = null); public static StreamingChatToolCallUpdate StreamingChatToolCallUpdate(int index = 0, string toolCallId = null, ChatToolCallKind kind = ChatToolCallKind.Function, string functionName = null, BinaryData functionArgumentsUpdate = null); } public class StreamingChatCompletionUpdate : IJsonModel, IPersistableModel { @@ -1503,7 +1504,7 @@ public class StreamingChatCompletionUpdate : IJsonModel RefusalTokenLogProbabilities { get; } public string RefusalUpdate { get; } - public ChatResponseAudio ResponseAudio { get; } + public StreamingChatResponseAudioUpdate ResponseAudioUpdate { get; } public ChatMessageRole? Role { get; } public string SystemFingerprint { get; } public IReadOnlyList ToolCallUpdates { get; } @@ -1518,6 +1519,14 @@ public class StreamingChatFunctionCallUpdate : IJsonModel, IPersistableModel { + public BinaryData DataUpdate { get; } + public DateTimeOffset? ExpiresAt { get; } + public string Id { get; } + public string TranscriptUpdate { get; } + public static explicit operator StreamingChatResponseAudioUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingChatResponseAudioUpdate streamingChatResponseAudioUpdate); + } public class StreamingChatToolCallUpdate : IJsonModel, IPersistableModel { public BinaryData FunctionArgumentsUpdate { get; } public string FunctionName { get; } diff --git a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs index 848a47830..93e1b66e2 100644 --- a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs +++ b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs @@ -15,7 +15,7 @@ public void Example09_ChatWithAudio() ChatClient client = new("gpt-4o-audio-preview", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); // Input audio is provided to a request by adding an audio content part to a user message - string audioFilePath = Path.Combine("Assets", "whats_the_weather_pcm16_24khz_mono.wav"); + string audioFilePath = Path.Combine("Assets", "realtime_whats_the_weather_pcm16_24khz_mono.wav"); byte[] audioFileRawBytes = File.ReadAllBytes(audioFilePath); BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); List messages = diff --git a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs index f1df7a318..1a228b94d 100644 --- a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs +++ b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs @@ -16,7 +16,7 @@ public async Task Example09_ChatWithAudioAsync() ChatClient client = new("gpt-4o-audio-preview", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); // Input audio is provided to a request by adding an audio content part to a user message - string audioFilePath = Path.Combine("Assets", "whats_the_weather_pcm16_24khz_mono.wav"); + string audioFilePath = Path.Combine("Assets", "realtime_whats_the_weather_pcm16_24khz_mono.wav"); byte[] audioFileRawBytes = await File.ReadAllBytesAsync(audioFilePath); BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); List messages = diff --git a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs index 6a2a78016..4e568962b 100644 --- a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs @@ -102,6 +102,3 @@ internal readonly partial struct InternalCreateChatCompletionRequestModality { } [CodeGenModel("ChatCompletionRequestMessageContentPartAudioType")] internal readonly partial struct InternalChatCompletionRequestMessageContentPartAudioType { } -[CodeGenModel("ChatCompletionMessageAudioChunk")] -internal partial class InternalChatCompletionMessageAudioChunk { } - diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs index 171de51a5..80c111996 100644 --- a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs @@ -16,9 +16,4 @@ internal partial class InternalChatCompletionStreamResponseDelta /// The contents of the message. [CodeGenMember("Content")] public ChatMessageContent Content { get; } - - // CUSTOM: Changed type to share with non-streaming response audio. - /// The incremental response audio information for the message. - [CodeGenMember("Audio")] - public ChatResponseAudio Audio { get; } } diff --git a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs index 3b87a1416..0e980a960 100644 --- a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs +++ b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -147,7 +147,7 @@ public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate( string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, - ChatResponseAudio responseAudio = null) + StreamingChatResponseAudioUpdate responseAudioUpdate = null) { contentUpdate ??= new ChatMessageContent(); toolCallUpdates ??= new List(); @@ -155,12 +155,12 @@ public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate( refusalTokenLogProbabilities ??= new List(); InternalChatCompletionStreamResponseDelta delta = new InternalChatCompletionStreamResponseDelta( + responseAudioUpdate, functionCallUpdate, toolCallUpdates.ToList(), refusalUpdate, role, contentUpdate, - responseAudio, additionalBinaryDataProperties: null); InternalCreateChatCompletionStreamResponseChoiceLogprobs logprobs = new InternalCreateChatCompletionStreamResponseChoiceLogprobs( @@ -200,6 +200,28 @@ public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(st additionalBinaryDataProperties: null); } + /// + /// Initializes a new instance of . + /// + /// + /// + /// + /// + /// + public static StreamingChatResponseAudioUpdate StreamingChatResponseAudioUpdate( + string id = null, + DateTimeOffset? expiresAt = null, + string transcriptUpdate = null, + BinaryData dataUpdate = null) + { + return new StreamingChatResponseAudioUpdate( + id, + expiresAt, + transcriptUpdate, + dataUpdate, + additionalBinaryDataProperties: null); + } + /// Initializes a new instance of . /// A new instance for mocking. public static StreamingChatToolCallUpdate StreamingChatToolCallUpdate(int index = default, string toolCallId = null, ChatToolCallKind kind = default, string functionName = null, BinaryData functionArgumentsUpdate = null) diff --git a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs index 1707f1aaf..98f4552d6 100644 --- a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs +++ b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs @@ -110,5 +110,5 @@ public IReadOnlyList ToolCallUpdates [Obsolete($"This property is obsolete. Please use {nameof(ToolCallUpdates)} instead.")] public StreamingChatFunctionCallUpdate FunctionCallUpdate => InternalChoiceDelta?.FunctionCall; - public ChatResponseAudio ResponseAudio => InternalChoiceDelta?.Audio; + public StreamingChatResponseAudioUpdate ResponseAudioUpdate => InternalChoiceDelta?.Audio; } diff --git a/.dotnet/src/Custom/Chat/Streaming/StreamingChatResponseAudioUpdate.cs b/.dotnet/src/Custom/Chat/Streaming/StreamingChatResponseAudioUpdate.cs new file mode 100644 index 000000000..0567d18d8 --- /dev/null +++ b/.dotnet/src/Custom/Chat/Streaming/StreamingChatResponseAudioUpdate.cs @@ -0,0 +1,28 @@ +namespace OpenAI.Chat; + +using System; + +/// +/// Represents an audio update in a streaming chat response. +/// +[CodeGenModel("ChatCompletionMessageAudioChunk")] +public partial class StreamingChatResponseAudioUpdate +{ + // CUSTOM: Renamed for clarity of incremental data availability while streaming. + /// + /// The next, incremental audio transcript part from the streaming response. payloads + /// across all received instances should be concatenated to form the + /// full response audio transcript. + /// + [CodeGenMember("Transcript")] + public string TranscriptUpdate { get; } + + // CUSTOM: Renamed for clarity of incremental data availability while streaming. + /// + /// The next, incremental response audio data chunk from the streaming response. payloads + /// across all received instances should be concatenated to form the + /// full response audio. + /// + [CodeGenMember("Data")] + public BinaryData DataUpdate { get; } +} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs index 217b7e4b1..a67a17260 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs @@ -27,6 +27,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(InternalChatCompletionStreamResponseDelta)} does not support writing '{format}' format."); } + if (Optional.IsDefined(Audio) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) + { + writer.WritePropertyName("audio"u8); + writer.WriteObjectValue(Audio, options); + } if (Optional.IsDefined(FunctionCall) && _additionalBinaryDataProperties?.ContainsKey("function_call") != true) { writer.WritePropertyName("function_call"u8); @@ -72,11 +77,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteNull("content"u8); } } - if (Optional.IsDefined(Audio) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) - { - writer.WritePropertyName("audio"u8); - writer.WriteObjectValue(Audio, options); - } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -117,15 +117,24 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha { return null; } + StreamingChatResponseAudioUpdate audio = default; StreamingChatFunctionCallUpdate functionCall = default; IReadOnlyList toolCalls = default; string refusal = default; Chat.ChatMessageRole? role = default; ChatMessageContent content = default; - ChatResponseAudio audio = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { + if (prop.NameEquals("audio"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + audio = StreamingChatResponseAudioUpdate.DeserializeStreamingChatResponseAudioUpdate(prop.Value, options); + continue; + } if (prop.NameEquals("function_call"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) @@ -173,15 +182,6 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha DeserializeContentValue(prop, ref content); continue; } - if (prop.NameEquals("audio"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - audio = ChatResponseAudio.DeserializeChatResponseAudio(prop.Value, options); - continue; - } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -189,12 +189,12 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha } // CUSTOM: Initialize Content collection property. return new InternalChatCompletionStreamResponseDelta( + audio, functionCall, toolCalls ?? new ChangeTrackingList(), refusal, role, content ?? new ChatMessageContent(), - audio, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs index ac361d1d1..7882baf06 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs @@ -11,17 +11,19 @@ internal partial class InternalChatCompletionStreamResponseDelta { private protected IDictionary _additionalBinaryDataProperties; - internal InternalChatCompletionStreamResponseDelta(StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, string refusal, Chat.ChatMessageRole? role, ChatMessageContent content, ChatResponseAudio audio, IDictionary additionalBinaryDataProperties) + internal InternalChatCompletionStreamResponseDelta(StreamingChatResponseAudioUpdate audio, StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, string refusal, Chat.ChatMessageRole? role, ChatMessageContent content, IDictionary additionalBinaryDataProperties) { + Audio = audio; FunctionCall = functionCall; ToolCalls = toolCalls; Refusal = refusal; Role = role; Content = content; - Audio = audio; _additionalBinaryDataProperties = additionalBinaryDataProperties; } + public StreamingChatResponseAudioUpdate Audio { get; } + public StreamingChatFunctionCallUpdate FunctionCall { get; } public IReadOnlyList ToolCalls { get; } diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.Serialization.cs b/.dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.Serialization.cs similarity index 55% rename from .dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.Serialization.cs rename to .dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.Serialization.cs index 9b3f2429d..0320683ab 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.Serialization.cs +++ b/.dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.Serialization.cs @@ -11,9 +11,9 @@ namespace OpenAI.Chat { - internal partial class InternalChatCompletionMessageAudioChunk : IJsonModel + public partial class StreamingChatResponseAudioUpdate : IJsonModel { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -22,30 +22,30 @@ void IJsonModel.Write(Utf8JsonWriter wr protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalChatCompletionMessageAudioChunk)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(StreamingChatResponseAudioUpdate)} does not support writing '{format}' format."); } if (Optional.IsDefined(Id) && _additionalBinaryDataProperties?.ContainsKey("id") != true) { writer.WritePropertyName("id"u8); writer.WriteStringValue(Id); } - if (Optional.IsDefined(Transcript) && _additionalBinaryDataProperties?.ContainsKey("transcript") != true) + if (Optional.IsDefined(ExpiresAt) && _additionalBinaryDataProperties?.ContainsKey("expires_at") != true) { - writer.WritePropertyName("transcript"u8); - writer.WriteStringValue(Transcript); + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt.Value, "U"); } - if (Optional.IsDefined(Data) && _additionalBinaryDataProperties?.ContainsKey("data") != true) + if (Optional.IsDefined(TranscriptUpdate) && _additionalBinaryDataProperties?.ContainsKey("transcript") != true) { - writer.WritePropertyName("data"u8); - writer.WriteBase64StringValue(Data.ToArray(), "D"); + writer.WritePropertyName("transcript"u8); + writer.WriteStringValue(TranscriptUpdate); } - if (Optional.IsDefined(ExpiresAt) && _additionalBinaryDataProperties?.ContainsKey("expires_at") != true) + if (Optional.IsDefined(DataUpdate) && _additionalBinaryDataProperties?.ContainsKey("data") != true) { - writer.WritePropertyName("expires_at"u8); - writer.WriteNumberValue(ExpiresAt.Value, "U"); + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(DataUpdate.ToArray(), "D"); } if (true && _additionalBinaryDataProperties != null) { @@ -68,29 +68,29 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalChatCompletionMessageAudioChunk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + StreamingChatResponseAudioUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual InternalChatCompletionMessageAudioChunk JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual StreamingChatResponseAudioUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalChatCompletionMessageAudioChunk)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(StreamingChatResponseAudioUpdate)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionMessageAudioChunk(document.RootElement, options); + return DeserializeStreamingChatResponseAudioUpdate(document.RootElement, options); } - internal static InternalChatCompletionMessageAudioChunk DeserializeInternalChatCompletionMessageAudioChunk(JsonElement element, ModelReaderWriterOptions options) + internal static StreamingChatResponseAudioUpdate DeserializeStreamingChatResponseAudioUpdate(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { return null; } string id = default; - string transcript = default; - BinaryData data = default; DateTimeOffset? expiresAt = default; + string transcriptUpdate = default; + BinaryData dataUpdate = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -99,27 +99,27 @@ internal static InternalChatCompletionMessageAudioChunk DeserializeInternalChatC id = prop.Value.GetString(); continue; } - if (prop.NameEquals("transcript"u8)) - { - transcript = prop.Value.GetString(); - continue; - } - if (prop.NameEquals("data"u8)) + if (prop.NameEquals("expires_at"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - data = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); + expiresAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); continue; } - if (prop.NameEquals("expires_at"u8)) + if (prop.NameEquals("transcript"u8)) + { + transcriptUpdate = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("data"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expiresAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + dataUpdate = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); continue; } if (true) @@ -127,56 +127,56 @@ internal static InternalChatCompletionMessageAudioChunk DeserializeInternalChatC additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalChatCompletionMessageAudioChunk(id, transcript, data, expiresAt, additionalBinaryDataProperties); + return new StreamingChatResponseAudioUpdate(id, expiresAt, transcriptUpdate, dataUpdate, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalChatCompletionMessageAudioChunk)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingChatResponseAudioUpdate)} does not support writing '{options.Format}' format."); } } - InternalChatCompletionMessageAudioChunk IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + StreamingChatResponseAudioUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual InternalChatCompletionMessageAudioChunk PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual StreamingChatResponseAudioUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeInternalChatCompletionMessageAudioChunk(document.RootElement, options); + return DeserializeStreamingChatResponseAudioUpdate(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalChatCompletionMessageAudioChunk)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingChatResponseAudioUpdate)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(InternalChatCompletionMessageAudioChunk internalChatCompletionMessageAudioChunk) + public static implicit operator BinaryContent(StreamingChatResponseAudioUpdate streamingChatResponseAudioUpdate) { - if (internalChatCompletionMessageAudioChunk == null) + if (streamingChatResponseAudioUpdate == null) { return null; } - return BinaryContent.Create(internalChatCompletionMessageAudioChunk, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(streamingChatResponseAudioUpdate, ModelSerializationExtensions.WireOptions); } - public static explicit operator InternalChatCompletionMessageAudioChunk(ClientResult result) + public static explicit operator StreamingChatResponseAudioUpdate(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionMessageAudioChunk(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeStreamingChatResponseAudioUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.cs b/.dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.cs similarity index 59% rename from .dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.cs rename to .dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.cs index bcd9a79b8..31f1133bc 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionMessageAudioChunk.cs +++ b/.dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.cs @@ -7,29 +7,25 @@ namespace OpenAI.Chat { - internal partial class InternalChatCompletionMessageAudioChunk + public partial class StreamingChatResponseAudioUpdate { private protected IDictionary _additionalBinaryDataProperties; - internal InternalChatCompletionMessageAudioChunk() + internal StreamingChatResponseAudioUpdate() { } - internal InternalChatCompletionMessageAudioChunk(string id, string transcript, BinaryData data, DateTimeOffset? expiresAt, IDictionary additionalBinaryDataProperties) + internal StreamingChatResponseAudioUpdate(string id, DateTimeOffset? expiresAt, string transcriptUpdate, BinaryData dataUpdate, IDictionary additionalBinaryDataProperties) { Id = id; - Transcript = transcript; - Data = data; ExpiresAt = expiresAt; + TranscriptUpdate = transcriptUpdate; + DataUpdate = dataUpdate; _additionalBinaryDataProperties = additionalBinaryDataProperties; } public string Id { get; } - public string Transcript { get; } - - public BinaryData Data { get; } - public DateTimeOffset? ExpiresAt { get; } internal IDictionary SerializedAdditionalRawData diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index 096e66a75..ff3ba3312 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -1259,6 +1259,12 @@ public static ChatMessageContentPart ChatMessageContentPart(Chat.ChatMessageCont serializedAdditionalRawData: null); } + public static StreamingChatResponseAudioUpdate StreamingChatResponseAudioUpdate(string id = default, DateTimeOffset? expiresAt = default, string transcriptUpdate = default, BinaryData dataUpdate = default) + { + + return new StreamingChatResponseAudioUpdate(id, expiresAt, transcriptUpdate, dataUpdate, additionalBinaryDataProperties: null); + } + public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionName = default, BinaryData functionArgumentsUpdate = default) { diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index 3a6da8060..bf98864f9 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -414,22 +414,36 @@ public async Task ChatWithAudio() ])); string streamedCorrelationId = null; + DateTimeOffset? streamedExpiresAt = null; + StringBuilder streamedTranscriptBuilder = new(); using MemoryStream responseAudioStream = new(); await foreach (StreamingChatCompletionUpdate update in client.CompleteChatStreamingAsync(messages, options)) { Assert.That(update.ContentUpdate, Has.Count.EqualTo(0)); - ChatResponseAudio responseAudioUpdate = update.ResponseAudio; + StreamingChatResponseAudioUpdate responseAudioUpdate = update.ResponseAudioUpdate; + if (responseAudioUpdate is not null) { + string serializedResponseAudioUpdate = ModelReaderWriter.Write(responseAudioUpdate).ToString(); + Assert.That(serializedResponseAudioUpdate, Is.Not.Null.And.Not.Empty); + if (responseAudioUpdate.Id is not null) { - Assert.That(streamedCorrelationId, Is.Null.Or.EqualTo(responseAudioUpdate.Id)); + Assert.That(streamedCorrelationId, Is.Null.Or.EqualTo(streamedCorrelationId)); streamedCorrelationId = responseAudioUpdate.Id; } - responseAudioStream.Write(responseAudioUpdate.Data); + if (responseAudioUpdate.ExpiresAt.HasValue) + { + Assert.That(streamedExpiresAt.HasValue, Is.False); + streamedExpiresAt = responseAudioUpdate.ExpiresAt; + } + streamedTranscriptBuilder.Append(responseAudioUpdate.TranscriptUpdate); + responseAudioStream.Write(responseAudioUpdate.DataUpdate); } } Assert.That(streamedCorrelationId, Is.Not.Null.And.Not.Empty); + Assert.That(streamedExpiresAt.HasValue, Is.True); + Assert.That(streamedTranscriptBuilder.ToString(), Is.Not.Null.And.Not.Empty); Assert.That(responseAudioStream.Length, Is.GreaterThan(9000)); } diff --git a/.scripts/Edit-Serialization.ps1 b/.scripts/Edit-Serialization.ps1 index 9e1be0160..057f21e7d 100644 --- a/.scripts/Edit-Serialization.ps1 +++ b/.scripts/Edit-Serialization.ps1 @@ -45,23 +45,23 @@ Update-In-File-With-Retry ` -FilePath "$directory\InternalChatCompletionStreamResponseDelta.Serialization.cs" ` -SearchPatternLines @( "return new InternalChatCompletionStreamResponseDelta\(" + " audio," " functionCall," " toolCalls \?\? new ChangeTrackingList\(\)," " refusal," " role," " content," - " audio," " additionalBinaryDataProperties\);" ) ` -ReplacePatternLines @( "// CUSTOM: Initialize Content collection property." "return new InternalChatCompletionStreamResponseDelta(" + " audio," " functionCall," " toolCalls ?? new ChangeTrackingList()," " refusal," " role," " content ?? new ChatMessageContent()," - " audio," " additionalBinaryDataProperties);" ) ` -OutputIndentation 12 ` From 20a0f9cedf9d86b1282767d78cab032a2c262e2f Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 16 Jan 2025 16:38:20 -0800 Subject: [PATCH 10/44] update readme for streaming accuracy and explanation --- .dotnet/README.md | 8 ++++++-- .dotnet/tests/Chat/ChatTests.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.dotnet/README.md b/.dotnet/README.md index 122070d2c..1513d65ec 100644 --- a/.dotnet/README.md +++ b/.dotnet/README.md @@ -414,8 +414,12 @@ completion = client.CompleteChat(messages, options); PrintAudioContent(); ``` -Streaming is virtually identical: items in `StreamingChatCompletionUpdate.ContentUpdate` will provide incremental chunks of data via -`AudioBytes` and `AudioTranscript`. +Streaming is highly parallel: `StreamingChatCompletionUpdate` instances can include a `ResponseAudioUpdate` that may +contain any of: + +- The `Id` of the streamed audio content, which can be referenced by subsequent `AssistantChatMessage` instances via `ChatAudioReference` once the streaming response is complete; this may appear across multiple `StreamingChatCompletionUpdate` instances but will always be the same value when present +- The `ExpiresAt` value that describes when the `Id` will no longer be valid for use with `ChatAudioReference` in subsequent requests; this typically appears once and only once, in the final `StreamingResponseAudioUpdate` +- Incremental `TranscriptUpdate` and/or `DataUpdate` values, which can incrementally consumed and, when concatenated, form the complete audio transcript and audio output for the overall response; many of these typically appear ## How to generate text embeddings diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index bf98864f9..c20df8200 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -430,7 +430,7 @@ public async Task ChatWithAudio() if (responseAudioUpdate.Id is not null) { Assert.That(streamedCorrelationId, Is.Null.Or.EqualTo(streamedCorrelationId)); - streamedCorrelationId = responseAudioUpdate.Id; + streamedCorrelationId ??= responseAudioUpdate.Id; } if (responseAudioUpdate.ExpiresAt.HasValue) { From 6a1a7ee608ea75d3a04b9571e77d0644b8fc9cb2 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 16 Jan 2025 17:09:21 -0800 Subject: [PATCH 11/44] 'responseaudio' to 'outputaudio', doc comments and cleaup --- .dotnet/CHANGELOG.md | 4 +- .dotnet/README.md | 18 ++-- .dotnet/api/OpenAI.netstandard2.0.cs | 94 +++++++++---------- .../examples/Chat/Example09_ChatWithAudio.cs | 12 +-- .../Chat/Example10_ChatWithAudioAsync.cs | 12 +-- .../AssistantChatMessage.Serialization.cs | 2 +- .../src/Custom/Chat/AssistantChatMessage.cs | 14 +-- .dotnet/src/Custom/Chat/ChatAudioOptions.cs | 2 +- .dotnet/src/Custom/Chat/ChatCompletion.cs | 2 +- .dotnet/src/Custom/Chat/ChatMessage.cs | 4 +- .../ChatMessageContentPart.Serialization.cs | 2 +- .../src/Custom/Chat/ChatMessageContentPart.cs | 8 +- ...hatMessageContentPartKind.Serialization.cs | 4 +- .../Custom/Chat/ChatMessageContentPartKind.cs | 2 +- ...hatResponseAudio.cs => ChatOutputAudio.cs} | 5 +- .../src/Custom/Chat/ChatOutputAudioFormat.cs | 4 + .../Custom/Chat/ChatOutputAudioReference.cs | 20 ++++ .../src/Custom/Chat/ChatOutputAudioVoice.cs | 14 +++ .../Custom/Chat/ChatResponseAudioReference.cs | 10 -- .dotnet/src/Custom/Chat/ChatResponseVoice.cs | 11 --- .../Custom/Chat/Internal/GeneratorStubs.cs | 5 + ...ompletionRequestMessageContentPartAudio.cs | 11 --- ...equestMessageContentPartAudioInputAudio.cs | 10 -- .../src/Custom/Chat/OpenAIChatModelFactory.cs | 18 ++-- .../StreamingChatCompletionUpdate.cs | 7 +- ...e.cs => StreamingChatOutputAudioUpdate.cs} | 2 +- .../AssistantChatMessage.Serialization.cs | 14 +-- .../Generated/Models/AssistantChatMessage.cs | 4 +- .../Models/ChatAudioOptions.Serialization.cs | 8 +- .../src/Generated/Models/ChatAudioOptions.cs | 8 +- ...on.cs => ChatOutputAudio.Serialization.cs} | 52 +++++----- ...hatResponseAudio.cs => ChatOutputAudio.cs} | 6 +- ...ChatOutputAudioReference.Serialization.cs} | 52 +++++----- ...ference.cs => ChatOutputAudioReference.cs} | 6 +- .../Generated/Models/ChatOutputAudioVoice.cs | 56 +++++++++++ .../src/Generated/Models/ChatResponseVoice.cs | 56 ----------- ...CompletionResponseMessage.Serialization.cs | 4 +- .../InternalChatCompletionResponseMessage.cs | 4 +- ...letionStreamResponseDelta.Serialization.cs | 4 +- ...ternalChatCompletionStreamResponseDelta.cs | 4 +- ...onRequestAssistantMessage.Serialization.cs | 8 +- ...neChatCompletionRequestAssistantMessage.cs | 2 +- ...ingChatOutputAudioUpdate.Serialization.cs} | 50 +++++----- ...e.cs => StreamingChatOutputAudioUpdate.cs} | 6 +- .dotnet/src/Generated/OpenAIModelFactory.cs | 20 ++-- .dotnet/tests/Chat/ChatSmokeTests.cs | 16 ++-- .dotnet/tests/Chat/ChatTests.cs | 38 ++++---- .scripts/Edit-Serialization.ps1 | 8 +- openapi3-original.yaml | 16 ++-- 49 files changed, 374 insertions(+), 365 deletions(-) rename .dotnet/src/Custom/Chat/{ChatResponseAudio.cs => ChatOutputAudio.cs} (51%) create mode 100644 .dotnet/src/Custom/Chat/ChatOutputAudioReference.cs create mode 100644 .dotnet/src/Custom/Chat/ChatOutputAudioVoice.cs delete mode 100644 .dotnet/src/Custom/Chat/ChatResponseAudioReference.cs delete mode 100644 .dotnet/src/Custom/Chat/ChatResponseVoice.cs delete mode 100644 .dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudio.cs delete mode 100644 .dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs rename .dotnet/src/Custom/Chat/Streaming/{StreamingChatResponseAudioUpdate.cs => StreamingChatOutputAudioUpdate.cs} (95%) rename .dotnet/src/Generated/Models/{ChatResponseAudio.Serialization.cs => ChatOutputAudio.Serialization.cs} (67%) rename .dotnet/src/Generated/Models/{ChatResponseAudio.cs => ChatOutputAudio.cs} (74%) rename .dotnet/src/Generated/Models/{ChatResponseAudioReference.Serialization.cs => ChatOutputAudioReference.Serialization.cs} (57%) rename .dotnet/src/Generated/Models/{ChatResponseAudioReference.cs => ChatOutputAudioReference.cs} (75%) create mode 100644 .dotnet/src/Generated/Models/ChatOutputAudioVoice.cs delete mode 100644 .dotnet/src/Generated/Models/ChatResponseVoice.cs rename .dotnet/src/Generated/Models/{StreamingChatResponseAudioUpdate.Serialization.cs => StreamingChatOutputAudioUpdate.Serialization.cs} (66%) rename .dotnet/src/Generated/Models/{StreamingChatResponseAudioUpdate.cs => StreamingChatOutputAudioUpdate.cs} (71%) diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index 1d88ffe18..ed1e12043 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -7,8 +7,8 @@ - Chat completion now supports audio input and output! - To configure a chat completion to request audio output using the `gpt-4o-audio-preview` model, create a `ChatAudioOptions` instance and provide it on `ChatCompletionOptions.AudioOptions`. - Input chat audio is provided to `UserChatMessage` instances using `ChatContentPart.CreateInputAudioPart()` - - Output chat audio is provided on the `ResponseAudio` property of `ChatCompletion` - - References to prior assistant audio are provided via `ResponseAudioReference` instances on the `AudioReference` property of `AssistantChatMessage`; `AssistantChatMessage(chatCompletion)` will automatically handle this, too + - Output chat audio is provided on the `OutputAudio` property of `ChatCompletion` + - References to prior assistant audio are provided via `OutputAudioReference` instances on the `AudioReference` property of `AssistantChatMessage`; `AssistantChatMessage(chatCompletion)` will automatically handle this, too - For more information, see the example in the README ## 2.1.0 (2024-12-04) diff --git a/.dotnet/README.md b/.dotnet/README.md index 1513d65ec..70cc32629 100644 --- a/.dotnet/README.md +++ b/.dotnet/README.md @@ -382,30 +382,30 @@ List messages = // Output audio is requested by configuring AudioOptions on ChatCompletionOptions ChatCompletionOptions options = new() { - AudioOptions = new(ChatResponseVoice.Alloy, ChatOutputAudioFormat.Mp3), + AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), }; ChatCompletion completion = client.CompleteChat(messages, options); void PrintAudioContent() { - if (completion.ResponseAudio is ChatResponseAudio responseAudio) + if (completion.OutputAudio is ChatOutputAudio outputAudio) { - Console.WriteLine($"Response audio transcript: {responseAudio.Transcript}"); - string outputFilePath = $"{responseAudio.Id}.mp3"; + Console.WriteLine($"Response audio transcript: {outputAudio.Transcript}"); + string outputFilePath = $"{outputAudio.Id}.mp3"; using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) { - outputFileStream.Write(responseAudio.Data); + outputFileStream.Write(outputAudio.Data); } Console.WriteLine($"Response audio written to file: {outputFilePath}"); - Console.WriteLine($"Valid on followup requests until: {responseAudio.ExpiresAt}"); + Console.WriteLine($"Valid on followup requests until: {outputAudio.ExpiresAt}"); } } PrintAudioContent(); // To refer to past audio output, create an assistant message from the earlier ChatCompletion or instantiate a -// ChatResponseAudioReference(string) from the .Id of the completion's .ResponseAudio property. +// ChatOutputAudioReference(string) from the .Id of the completion's .OutputAudio property. messages.Add(new AssistantChatMessage(completion)); messages.Add("Can you say that like a pirate?"); @@ -414,11 +414,11 @@ completion = client.CompleteChat(messages, options); PrintAudioContent(); ``` -Streaming is highly parallel: `StreamingChatCompletionUpdate` instances can include a `ResponseAudioUpdate` that may +Streaming is highly parallel: `StreamingChatCompletionUpdate` instances can include a `OutputAudioUpdate` that may contain any of: - The `Id` of the streamed audio content, which can be referenced by subsequent `AssistantChatMessage` instances via `ChatAudioReference` once the streaming response is complete; this may appear across multiple `StreamingChatCompletionUpdate` instances but will always be the same value when present -- The `ExpiresAt` value that describes when the `Id` will no longer be valid for use with `ChatAudioReference` in subsequent requests; this typically appears once and only once, in the final `StreamingResponseAudioUpdate` +- The `ExpiresAt` value that describes when the `Id` will no longer be valid for use with `ChatAudioReference` in subsequent requests; this typically appears once and only once, in the final `StreamingOutputAudioUpdate` - Incremental `TranscriptUpdate` and/or `DataUpdate` values, which can incrementally consumed and, when concatenated, form the complete audio transcript and audio output for the overall response; many of these typically appear ## How to generate text embeddings diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index b9feef437..41bd69eb6 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1131,15 +1131,15 @@ public class AssistantChatMessage : ChatMessage, IJsonModel parameter instead.")] public AssistantChatMessage(ChatFunctionCall functionCall); public AssistantChatMessage(params ChatMessageContentPart[] contentParts); - public AssistantChatMessage(ChatResponseAudioReference responseAudioReference); + public AssistantChatMessage(ChatOutputAudioReference outputAudioReference); public AssistantChatMessage(IEnumerable contentParts); public AssistantChatMessage(IEnumerable toolCalls); public AssistantChatMessage(string content); [Obsolete("This property is obsolete. Please use ToolCalls instead.")] public ChatFunctionCall FunctionCall { get; set; } + public ChatOutputAudioReference OutputAudioReference { get; set; } public string ParticipantName { get; set; } public string Refusal { get; set; } - public ChatResponseAudioReference ResponseAudioReference { get; set; } public IList ToolCalls { get; } protected override ChatMessage JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options); protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options); @@ -1149,9 +1149,9 @@ public class AssistantChatMessage : ChatMessage, IJsonModel, IPersistableModel { - public ChatAudioOptions(ChatResponseVoice responseVoice, ChatOutputAudioFormat outputAudioFormat); + public ChatAudioOptions(ChatOutputAudioVoice outputAudioVoice, ChatOutputAudioFormat outputAudioFormat); public ChatOutputAudioFormat OutputAudioFormat { get; set; } - public ChatResponseVoice ResponseVoice { get; set; } + public ChatOutputAudioVoice OutputAudioVoice { get; set; } public static explicit operator ChatAudioOptions(ClientResult result); public static implicit operator BinaryContent(ChatAudioOptions chatAudioOptions); } @@ -1184,9 +1184,9 @@ public class ChatCompletion : IJsonModel, IPersistableModel RefusalTokenLogProbabilities { get; } - public ChatResponseAudio ResponseAudio { get; } public ChatMessageRole Role { get; } public string SystemFingerprint { get; } public IReadOnlyList ToolCalls { get; } @@ -1292,7 +1292,7 @@ public class ChatMessage : IJsonModel, IPersistableModel contentParts); public static AssistantChatMessage CreateAssistantMessage(IEnumerable toolCalls); public static AssistantChatMessage CreateAssistantMessage(string content); @@ -1340,7 +1340,7 @@ public enum ChatMessageContentPartKind { Text = 0, Refusal = 1, Image = 2, - Audio = 3 + InputAudio = 3 } public enum ChatMessageRole { System = 0, @@ -1349,6 +1349,14 @@ public enum ChatMessageRole { Tool = 3, Function = 4 } + public class ChatOutputAudio : IJsonModel, IPersistableModel { + public BinaryData Data { get; } + public DateTimeOffset ExpiresAt { get; } + public string Id { get; } + public string Transcript { get; } + public static explicit operator ChatOutputAudio(ClientResult result); + public static implicit operator BinaryContent(ChatOutputAudio chatOutputAudio); + } public readonly partial struct ChatOutputAudioFormat : IEquatable { public ChatOutputAudioFormat(string value); public static ChatOutputAudioFormat Flac { get; } @@ -1366,26 +1374,36 @@ public enum ChatMessageRole { public static bool operator !=(ChatOutputAudioFormat left, ChatOutputAudioFormat right); public override readonly string ToString(); } + public class ChatOutputAudioReference : IJsonModel, IPersistableModel { + public ChatOutputAudioReference(string id); + public string Id { get; } + public static explicit operator ChatOutputAudioReference(ClientResult result); + public static implicit operator BinaryContent(ChatOutputAudioReference chatOutputAudioReference); + } + public readonly partial struct ChatOutputAudioVoice : IEquatable { + public ChatOutputAudioVoice(string value); + public static ChatOutputAudioVoice Alloy { get; } + public static ChatOutputAudioVoice Echo { get; } + public static ChatOutputAudioVoice Fable { get; } + public static ChatOutputAudioVoice Nova { get; } + public static ChatOutputAudioVoice Onyx { get; } + public static ChatOutputAudioVoice Shimmer { get; } + public readonly bool Equals(ChatOutputAudioVoice other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(ChatOutputAudioVoice left, ChatOutputAudioVoice right); + public static implicit operator ChatOutputAudioVoice(string value); + public static bool operator !=(ChatOutputAudioVoice left, ChatOutputAudioVoice right); + public override readonly string ToString(); + } public class ChatOutputTokenUsageDetails : IJsonModel, IPersistableModel { public int AudioTokenCount { get; } public int ReasoningTokenCount { get; } public static explicit operator ChatOutputTokenUsageDetails(ClientResult result); public static implicit operator BinaryContent(ChatOutputTokenUsageDetails chatOutputTokenUsageDetails); } - public class ChatResponseAudio : IJsonModel, IPersistableModel { - public BinaryData Data { get; } - public DateTimeOffset ExpiresAt { get; } - public string Id { get; } - public string Transcript { get; } - public static explicit operator ChatResponseAudio(ClientResult result); - public static implicit operator BinaryContent(ChatResponseAudio chatResponseAudio); - } - public class ChatResponseAudioReference : IJsonModel, IPersistableModel { - public ChatResponseAudioReference(string id); - public string Id { get; } - public static explicit operator ChatResponseAudioReference(ClientResult result); - public static implicit operator BinaryContent(ChatResponseAudioReference chatResponseAudioReference); - } public class ChatResponseFormat : IJsonModel, IPersistableModel { public static ChatResponseFormat CreateJsonObjectFormat(); public static ChatResponseFormat CreateJsonSchemaFormat(string jsonSchemaFormatName, BinaryData jsonSchema, string jsonSchemaFormatDescription = null, bool? jsonSchemaIsStrict = null); @@ -1393,24 +1411,6 @@ public class ChatResponseFormat : IJsonModel, IPersistableMo public static explicit operator ChatResponseFormat(ClientResult result); public static implicit operator BinaryContent(ChatResponseFormat chatResponseFormat); } - public readonly partial struct ChatResponseVoice : IEquatable { - public ChatResponseVoice(string value); - public static ChatResponseVoice Alloy { get; } - public static ChatResponseVoice Echo { get; } - public static ChatResponseVoice Fable { get; } - public static ChatResponseVoice Nova { get; } - public static ChatResponseVoice Onyx { get; } - public static ChatResponseVoice Shimmer { get; } - public readonly bool Equals(ChatResponseVoice other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(ChatResponseVoice left, ChatResponseVoice right); - public static implicit operator ChatResponseVoice(string value); - public static bool operator !=(ChatResponseVoice left, ChatResponseVoice right); - public override readonly string ToString(); - } public class ChatTokenLogProbabilityDetails : IJsonModel, IPersistableModel { public float LogProbability { get; } public string Token { get; } @@ -1480,17 +1480,17 @@ public class FunctionChatMessage : ChatMessage, IJsonModel, protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options); } public static class OpenAIChatModelFactory { - public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatResponseAudio responseAudio = null); + public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatOutputAudio outputAudio = null); public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = 0, int cachedTokenCount = 0); + public static ChatOutputAudio ChatOutputAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default); public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = 0, int audioTokenCount = 0); - public static ChatResponseAudio ChatResponseAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default); public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null); public static ChatTokenTopLogProbabilityDetails ChatTokenTopLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null); public static ChatTokenUsage ChatTokenUsage(int outputTokenCount = 0, int inputTokenCount = 0, int totalTokenCount = 0, ChatOutputTokenUsageDetails outputTokenDetails = null, ChatInputTokenUsageDetails inputTokenDetails = null); - public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string completionId = null, ChatMessageContent contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, StreamingChatResponseAudioUpdate responseAudioUpdate = null); + public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string completionId = null, ChatMessageContent contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, StreamingChatOutputAudioUpdate outputAudioUpdate = null); [Obsolete("This class is obsolete. Please use StreamingChatToolCallUpdate instead.")] public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionName = null, BinaryData functionArgumentsUpdate = null); - public static StreamingChatResponseAudioUpdate StreamingChatResponseAudioUpdate(string id = null, DateTimeOffset? expiresAt = null, string transcriptUpdate = null, BinaryData dataUpdate = null); + public static StreamingChatOutputAudioUpdate StreamingChatOutputAudioUpdate(string id = null, DateTimeOffset? expiresAt = null, string transcriptUpdate = null, BinaryData dataUpdate = null); public static StreamingChatToolCallUpdate StreamingChatToolCallUpdate(int index = 0, string toolCallId = null, ChatToolCallKind kind = ChatToolCallKind.Function, string functionName = null, BinaryData functionArgumentsUpdate = null); } public class StreamingChatCompletionUpdate : IJsonModel, IPersistableModel { @@ -1502,9 +1502,9 @@ public class StreamingChatCompletionUpdate : IJsonModel RefusalTokenLogProbabilities { get; } public string RefusalUpdate { get; } - public StreamingChatResponseAudioUpdate ResponseAudioUpdate { get; } public ChatMessageRole? Role { get; } public string SystemFingerprint { get; } public IReadOnlyList ToolCallUpdates { get; } @@ -1519,13 +1519,13 @@ public class StreamingChatFunctionCallUpdate : IJsonModel, IPersistableModel { + public class StreamingChatOutputAudioUpdate : IJsonModel, IPersistableModel { public BinaryData DataUpdate { get; } public DateTimeOffset? ExpiresAt { get; } public string Id { get; } public string TranscriptUpdate { get; } - public static explicit operator StreamingChatResponseAudioUpdate(ClientResult result); - public static implicit operator BinaryContent(StreamingChatResponseAudioUpdate streamingChatResponseAudioUpdate); + public static explicit operator StreamingChatOutputAudioUpdate(ClientResult result); + public static implicit operator BinaryContent(StreamingChatOutputAudioUpdate streamingChatOutputAudioUpdate); } public class StreamingChatToolCallUpdate : IJsonModel, IPersistableModel { public BinaryData FunctionArgumentsUpdate { get; } diff --git a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs index 93e1b66e2..821b2cf30 100644 --- a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs +++ b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs @@ -26,23 +26,23 @@ public void Example09_ChatWithAudio() // Output audio is requested by configuring AudioOptions on ChatCompletionOptions ChatCompletionOptions options = new() { - AudioOptions = new(ChatResponseVoice.Alloy, ChatOutputAudioFormat.Mp3), + AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), }; ChatCompletion completion = client.CompleteChat(messages, options); void PrintAudioContent() { - if (completion.ResponseAudio is ChatResponseAudio responseAudio) + if (completion.OutputAudio is ChatOutputAudio outputAudio) { - Console.WriteLine($"Response audio transcript: {responseAudio.Transcript}"); - string outputFilePath = $"{responseAudio.Id}.mp3"; + Console.WriteLine($"Response audio transcript: {outputAudio.Transcript}"); + string outputFilePath = $"{outputAudio.Id}.mp3"; using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) { - outputFileStream.Write(responseAudio.Data); + outputFileStream.Write(outputAudio.Data); } Console.WriteLine($"Response audio written to file: {outputFilePath}"); - Console.WriteLine($"Valid on followup requests until: {responseAudio.ExpiresAt}"); + Console.WriteLine($"Valid on followup requests until: {outputAudio.ExpiresAt}"); } } diff --git a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs index 1a228b94d..34ad5e7d7 100644 --- a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs +++ b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs @@ -27,23 +27,23 @@ public async Task Example09_ChatWithAudioAsync() // Output audio is requested by configuring AudioOptions on ChatCompletionOptions ChatCompletionOptions options = new() { - AudioOptions = new(ChatResponseVoice.Alloy, ChatOutputAudioFormat.Mp3), + AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), }; ChatCompletion completion = await client.CompleteChatAsync(messages, options); async Task PrintAudioContentAsync() { - if (completion.ResponseAudio is ChatResponseAudio responseAudio) + if (completion.OutputAudio is ChatOutputAudio outputAudio) { - Console.WriteLine($"Response audio transcript: {responseAudio.Transcript}"); - string outputFilePath = $"{responseAudio.Id}.mp3"; + Console.WriteLine($"Response audio transcript: {outputAudio.Transcript}"); + string outputFilePath = $"{outputAudio.Id}.mp3"; using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) { - await outputFileStream.WriteAsync(responseAudio.Data); + await outputFileStream.WriteAsync(outputAudio.Data); } Console.WriteLine($"Response audio written to file: {outputFilePath}"); - Console.WriteLine($"Valid on followup requests until: {responseAudio.ExpiresAt}"); + Console.WriteLine($"Valid on followup requests until: {outputAudio.ExpiresAt}"); } } diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs index 41fa66f7c..f12246a67 100644 --- a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs @@ -44,7 +44,7 @@ internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions writer.WriteOptionalProperty("name"u8, ParticipantName, options); writer.WriteOptionalCollection("tool_calls"u8, ToolCalls, options); writer.WriteOptionalProperty("function_call"u8, FunctionCall, options); - writer.WriteOptionalProperty("audio"u8, ResponseAudioReference, options); + writer.WriteOptionalProperty("audio"u8, OutputAudioReference, options); writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); writer.WriteEndObject(); } diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.cs b/.dotnet/src/Custom/Chat/AssistantChatMessage.cs index 261aaec9b..77d31bff5 100644 --- a/.dotnet/src/Custom/Chat/AssistantChatMessage.cs +++ b/.dotnet/src/Custom/Chat/AssistantChatMessage.cs @@ -88,12 +88,12 @@ public AssistantChatMessage(ChatFunctionCall functionCall) /// Creates a new instance of that represents a prior response from the model /// that included audio with a correlation ID. /// - /// The audio reference with an id, produced by the model. - public AssistantChatMessage(ChatResponseAudioReference responseAudioReference) + /// The audio reference with an id, produced by the model. + public AssistantChatMessage(ChatOutputAudioReference outputAudioReference) { - Argument.AssertNotNull(responseAudioReference, nameof(responseAudioReference)); + Argument.AssertNotNull(outputAudioReference, nameof(outputAudioReference)); - ResponseAudioReference = responseAudioReference; + OutputAudioReference = outputAudioReference; } /// @@ -122,9 +122,9 @@ public AssistantChatMessage(ChatCompletion chatCompletion) Refusal = chatCompletion.Refusal; FunctionCall = chatCompletion.FunctionCall; - if (chatCompletion.ResponseAudio is not null) + if (chatCompletion.OutputAudio is not null) { - ResponseAudioReference = new(chatCompletion.ResponseAudio.Id); + OutputAudioReference = new(chatCompletion.OutputAudio.Id); } foreach (ChatToolCall toolCall in chatCompletion.ToolCalls ?? []) { @@ -150,5 +150,5 @@ public AssistantChatMessage(ChatCompletion chatCompletion) // CUSTOM: Made internal for reprojected representation within the content collection. [CodeGenMember("Audio")] - public ChatResponseAudioReference ResponseAudioReference { get; set; } + public ChatOutputAudioReference OutputAudioReference { get; set; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatAudioOptions.cs b/.dotnet/src/Custom/Chat/ChatAudioOptions.cs index e06a1e3ed..5c07bfd4a 100644 --- a/.dotnet/src/Custom/Chat/ChatAudioOptions.cs +++ b/.dotnet/src/Custom/Chat/ChatAudioOptions.cs @@ -18,7 +18,7 @@ public partial class ChatAudioOptions /// Gets or sets the voice model that the response should use to synthesize audio. /// [CodeGenMember("Voice")] - public ChatResponseVoice ResponseVoice { get; set; } + public ChatOutputAudioVoice OutputAudioVoice { get; set; } /// /// Specifies the output format desired for synthesized audio. diff --git a/.dotnet/src/Custom/Chat/ChatCompletion.cs b/.dotnet/src/Custom/Chat/ChatCompletion.cs index ad76ca8b6..bb57e3c0f 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletion.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletion.cs @@ -86,5 +86,5 @@ public partial class ChatCompletion public ChatFunctionCall FunctionCall => Choices[0].Message.FunctionCall; /// The audio response generated by the model. - public ChatResponseAudio ResponseAudio => Choices[0].Message.Audio; + public ChatOutputAudio OutputAudio => Choices[0].Message.Audio; } diff --git a/.dotnet/src/Custom/Chat/ChatMessage.cs b/.dotnet/src/Custom/Chat/ChatMessage.cs index 4e2d91320..dd9ec8fba 100644 --- a/.dotnet/src/Custom/Chat/ChatMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatMessage.cs @@ -135,8 +135,8 @@ internal ChatMessage(ChatMessageRole role, string content = null) : this(role) /// public static AssistantChatMessage CreateAssistantMessage(ChatCompletion chatCompletion) => new(chatCompletion); - /// - public static AssistantChatMessage CreateAssistantMessage(ChatResponseAudioReference audioReference) => new(audioReference); + /// + public static AssistantChatMessage CreateAssistantMessage(ChatOutputAudioReference audioReference) => new(audioReference); #endregion diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs index 2b8d1b2e6..20faaf3f5 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPart.Serialization.cs @@ -33,7 +33,7 @@ internal static void WriteCoreContentPart(ChatMessageContentPart instance, Utf8J writer.WritePropertyName("image_url"u8); writer.WriteObjectValue(instance._imageUri, options); } - else if (instance._kind == ChatMessageContentPartKind.Audio) + else if (instance._kind == ChatMessageContentPartKind.InputAudio) { writer.WritePropertyName("input_audio"u8); writer.WriteObjectValue(instance._inputAudio, options); diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs index 295ae8ac9..8f144a196 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs @@ -84,7 +84,7 @@ internal ChatMessageContentPart( /// The encoded binary audio payload associated with the content part. /// /// - /// Present when is and the content part + /// Present when is . The content part /// represents user role audio input. /// public BinaryData AudioBytes => _inputAudio?.Data; @@ -93,7 +93,7 @@ internal ChatMessageContentPart( /// The encoding format that the audio data provided in should be interpreted with. /// /// - /// Present when is and the content part + /// Present when is . The content part /// represents user role audio input. /// public ChatInputAudioFormat? AudioInputFormat => _inputAudio?.Format; @@ -171,7 +171,7 @@ public static ChatMessageContentPart CreateRefusalPart(string refusal) /// Creates a new that encapsulates user role input audio in a known format. /// /// Binary audio content parts may only be used with instances to represent user audio input. When referring to - /// past audio output from the model, use instead. + /// past audio output from the model, use instead. /// /// The audio data. /// The format of the audio data. @@ -180,7 +180,7 @@ public static ChatMessageContentPart CreateInputAudioPart(BinaryData audioBytes, Argument.AssertNotNull(audioBytes, nameof(audioBytes)); return new ChatMessageContentPart( - kind: ChatMessageContentPartKind.Audio, + kind: ChatMessageContentPartKind.InputAudio, inputAudio: new(audioBytes, audioFormat)); } diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs index b2d6d397a..eae666c74 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.Serialization.cs @@ -13,7 +13,7 @@ internal static partial class ChatMessageContentPartKindExtensions ChatMessageContentPartKind.Text => "text", ChatMessageContentPartKind.Refusal => "refusal", ChatMessageContentPartKind.Image => "image_url", - ChatMessageContentPartKind.Audio => "input_audio", + ChatMessageContentPartKind.InputAudio => "input_audio", _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageContentPartKind value.") }; @@ -22,7 +22,7 @@ public static ChatMessageContentPartKind ToChatMessageContentPartKind(this strin if (StringComparer.OrdinalIgnoreCase.Equals(value, "text")) return ChatMessageContentPartKind.Text; if (StringComparer.OrdinalIgnoreCase.Equals(value, "refusal")) return ChatMessageContentPartKind.Refusal; if (StringComparer.OrdinalIgnoreCase.Equals(value, "image_url")) return ChatMessageContentPartKind.Image; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_audio")) return ChatMessageContentPartKind.Audio; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_audio")) return ChatMessageContentPartKind.InputAudio; throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageContentPartKind value."); } } diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.cs index 29c17ccc6..c371039b4 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPartKind.cs @@ -11,5 +11,5 @@ public enum ChatMessageContentPartKind Image, - Audio, + InputAudio, } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatResponseAudio.cs b/.dotnet/src/Custom/Chat/ChatOutputAudio.cs similarity index 51% rename from .dotnet/src/Custom/Chat/ChatResponseAudio.cs rename to .dotnet/src/Custom/Chat/ChatOutputAudio.cs index 54f1fe210..f8ddfa934 100644 --- a/.dotnet/src/Custom/Chat/ChatResponseAudio.cs +++ b/.dotnet/src/Custom/Chat/ChatOutputAudio.cs @@ -4,8 +4,11 @@ namespace OpenAI.Chat; +/// +/// Represents the audio output generated by the model as part of a chat completion response. +/// [CodeGenModel("ChatCompletionResponseMessageAudio")] -public partial class ChatResponseAudio +public partial class ChatOutputAudio { } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatOutputAudioFormat.cs b/.dotnet/src/Custom/Chat/ChatOutputAudioFormat.cs index f82ba8034..12cb5e909 100644 --- a/.dotnet/src/Custom/Chat/ChatOutputAudioFormat.cs +++ b/.dotnet/src/Custom/Chat/ChatOutputAudioFormat.cs @@ -4,6 +4,10 @@ namespace OpenAI.Chat; +/// +/// Specifies the audio format the model should use when generating output audio as part of a chat completion +/// response. +/// [CodeGenModel("CreateChatCompletionRequestAudioFormat")] public readonly partial struct ChatOutputAudioFormat { diff --git a/.dotnet/src/Custom/Chat/ChatOutputAudioReference.cs b/.dotnet/src/Custom/Chat/ChatOutputAudioReference.cs new file mode 100644 index 000000000..2991ca107 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatOutputAudioReference.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace OpenAI.Chat; + +/// +/// Represents an ID-based reference to a past audio output as received from a prior chat completion response, as +/// provided when creating an instance for use in a conversation history. +/// +/// +/// This value is obtained from the or +/// properties for streaming and non-streaming +/// responses, respectively. The constructor overload can also be +/// used to automatically populate the appropriate properties from a instance. +/// +[CodeGenModel("ChatCompletionRequestAssistantMessageAudio")] +public partial class ChatOutputAudioReference +{ +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatOutputAudioVoice.cs b/.dotnet/src/Custom/Chat/ChatOutputAudioVoice.cs new file mode 100644 index 000000000..4d8fc3bd1 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatOutputAudioVoice.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Chat; + +/// +/// Specifies the available voices that the model can use when generating output audio as part of a chat completion. +/// +[CodeGenModel("CreateChatCompletionRequestAudioVoice")] +public readonly partial struct ChatOutputAudioVoice +{ + +} diff --git a/.dotnet/src/Custom/Chat/ChatResponseAudioReference.cs b/.dotnet/src/Custom/Chat/ChatResponseAudioReference.cs deleted file mode 100644 index 2a6465202..000000000 --- a/.dotnet/src/Custom/Chat/ChatResponseAudioReference.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace OpenAI.Chat; - -[CodeGenModel("ChatCompletionRequestAssistantMessageAudio")] -public partial class ChatResponseAudioReference -{ -} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatResponseVoice.cs b/.dotnet/src/Custom/Chat/ChatResponseVoice.cs deleted file mode 100644 index ab875e421..000000000 --- a/.dotnet/src/Custom/Chat/ChatResponseVoice.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Chat; - -[CodeGenModel("CreateChatCompletionRequestAudioVoice")] -public readonly partial struct ChatResponseVoice -{ - -} diff --git a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs index 4e568962b..f9ab32374 100644 --- a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs @@ -102,3 +102,8 @@ internal readonly partial struct InternalCreateChatCompletionRequestModality { } [CodeGenModel("ChatCompletionRequestMessageContentPartAudioType")] internal readonly partial struct InternalChatCompletionRequestMessageContentPartAudioType { } +[CodeGenModel("ChatCompletionRequestMessageContentPartAudio")] +internal partial class InternalChatCompletionRequestMessageContentPartAudio { } + +[CodeGenModel("ChatCompletionRequestMessageContentPartAudioInputAudio")] +internal partial class InternalChatCompletionRequestMessageContentPartAudioInputAudio { } diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudio.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudio.cs deleted file mode 100644 index 0203c71b0..000000000 --- a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudio.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace OpenAI.Chat; - -[CodeGenModel("ChatCompletionRequestMessageContentPartAudio")] -internal partial class InternalChatCompletionRequestMessageContentPartAudio -{ - -} diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs deleted file mode 100644 index 08f25b5e1..000000000 --- a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionRequestMessageContentPartAudioInputAudio.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace OpenAI.Chat; - -[CodeGenModel("ChatCompletionRequestMessageContentPartAudioInputAudio")] -internal partial class InternalChatCompletionRequestMessageContentPartAudioInputAudio -{ -} diff --git a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs index 0e980a960..1493096b5 100644 --- a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs +++ b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -23,7 +23,7 @@ public static ChatCompletion ChatCompletion( string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, - ChatResponseAudio responseAudio = null) + ChatOutputAudio outputAudio = null) { content ??= new ChatMessageContent(); toolCalls ??= new List(); @@ -33,7 +33,7 @@ public static ChatCompletion ChatCompletion( InternalChatCompletionResponseMessage message = new InternalChatCompletionResponseMessage( refusal, toolCalls.ToList(), - responseAudio, + outputAudio, role, content, functionCall, @@ -121,9 +121,9 @@ public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reason return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, additionalBinaryDataProperties: null); } - public static ChatResponseAudio ChatResponseAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default) + public static ChatOutputAudio ChatOutputAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default) { - return new ChatResponseAudio( + return new ChatOutputAudio( id, expiresAt, data, @@ -147,7 +147,7 @@ public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate( string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, - StreamingChatResponseAudioUpdate responseAudioUpdate = null) + StreamingChatOutputAudioUpdate outputAudioUpdate = null) { contentUpdate ??= new ChatMessageContent(); toolCallUpdates ??= new List(); @@ -155,7 +155,7 @@ public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate( refusalTokenLogProbabilities ??= new List(); InternalChatCompletionStreamResponseDelta delta = new InternalChatCompletionStreamResponseDelta( - responseAudioUpdate, + outputAudioUpdate, functionCallUpdate, toolCallUpdates.ToList(), refusalUpdate, @@ -201,20 +201,20 @@ public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(st } /// - /// Initializes a new instance of . + /// Initializes a new instance of . /// /// /// /// /// /// - public static StreamingChatResponseAudioUpdate StreamingChatResponseAudioUpdate( + public static StreamingChatOutputAudioUpdate StreamingChatOutputAudioUpdate( string id = null, DateTimeOffset? expiresAt = null, string transcriptUpdate = null, BinaryData dataUpdate = null) { - return new StreamingChatResponseAudioUpdate( + return new StreamingChatOutputAudioUpdate( id, expiresAt, transcriptUpdate, diff --git a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs index 98f4552d6..28581f162 100644 --- a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs +++ b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs @@ -110,5 +110,10 @@ public IReadOnlyList ToolCallUpdates [Obsolete($"This property is obsolete. Please use {nameof(ToolCallUpdates)} instead.")] public StreamingChatFunctionCallUpdate FunctionCallUpdate => InternalChoiceDelta?.FunctionCall; - public StreamingChatResponseAudioUpdate ResponseAudioUpdate => InternalChoiceDelta?.Audio; + /// + /// Incremental output audio generated by the model. Only expected when output audio has been requested via providing + /// to and only available with + /// supported models. + /// + public StreamingChatOutputAudioUpdate OutputAudioUpdate => InternalChoiceDelta?.Audio; } diff --git a/.dotnet/src/Custom/Chat/Streaming/StreamingChatResponseAudioUpdate.cs b/.dotnet/src/Custom/Chat/Streaming/StreamingChatOutputAudioUpdate.cs similarity index 95% rename from .dotnet/src/Custom/Chat/Streaming/StreamingChatResponseAudioUpdate.cs rename to .dotnet/src/Custom/Chat/Streaming/StreamingChatOutputAudioUpdate.cs index 0567d18d8..a7a468b3e 100644 --- a/.dotnet/src/Custom/Chat/Streaming/StreamingChatResponseAudioUpdate.cs +++ b/.dotnet/src/Custom/Chat/Streaming/StreamingChatOutputAudioUpdate.cs @@ -6,7 +6,7 @@ namespace OpenAI.Chat; /// Represents an audio update in a streaming chat response. /// [CodeGenModel("ChatCompletionMessageAudioChunk")] -public partial class StreamingChatResponseAudioUpdate +public partial class StreamingChatOutputAudioUpdate { // CUSTOM: Renamed for clarity of incremental data availability while streaming. /// diff --git a/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs b/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs index 45fab83f5..529601ef0 100644 --- a/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/AssistantChatMessage.Serialization.cs @@ -60,12 +60,12 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteNull("functionCall"u8); } } - if (Optional.IsDefined(ResponseAudioReference) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) + if (Optional.IsDefined(OutputAudioReference) && _additionalBinaryDataProperties?.ContainsKey("audio") != true) { - if (ResponseAudioReference != null) + if (OutputAudioReference != null) { writer.WritePropertyName("audio"u8); - writer.WriteObjectValue(ResponseAudioReference, options); + writer.WriteObjectValue(OutputAudioReference, options); } else { @@ -100,7 +100,7 @@ internal static AssistantChatMessage DeserializeAssistantChatMessage(JsonElement string participantName = default; IList toolCalls = default; ChatFunctionCall functionCall = default; - ChatResponseAudioReference responseAudioReference = default; + ChatOutputAudioReference outputAudioReference = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("content"u8)) @@ -156,10 +156,10 @@ internal static AssistantChatMessage DeserializeAssistantChatMessage(JsonElement { if (prop.Value.ValueKind == JsonValueKind.Null) { - responseAudioReference = null; + outputAudioReference = null; continue; } - responseAudioReference = ChatResponseAudioReference.DeserializeChatResponseAudioReference(prop.Value, options); + outputAudioReference = ChatOutputAudioReference.DeserializeChatOutputAudioReference(prop.Value, options); continue; } if (true) @@ -176,7 +176,7 @@ internal static AssistantChatMessage DeserializeAssistantChatMessage(JsonElement participantName, toolCalls ?? new ChangeTrackingList(), functionCall, - responseAudioReference); + outputAudioReference); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/AssistantChatMessage.cs b/.dotnet/src/Generated/Models/AssistantChatMessage.cs index 6975e7bd3..0fd143349 100644 --- a/.dotnet/src/Generated/Models/AssistantChatMessage.cs +++ b/.dotnet/src/Generated/Models/AssistantChatMessage.cs @@ -9,13 +9,13 @@ namespace OpenAI.Chat { public partial class AssistantChatMessage : ChatMessage { - internal AssistantChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, ChatResponseAudioReference responseAudioReference) : base(content, role, additionalBinaryDataProperties) + internal AssistantChatMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, ChatOutputAudioReference outputAudioReference) : base(content, role, additionalBinaryDataProperties) { Refusal = refusal; ParticipantName = participantName; ToolCalls = toolCalls; FunctionCall = functionCall; - ResponseAudioReference = responseAudioReference; + OutputAudioReference = outputAudioReference; } public string Refusal { get; set; } diff --git a/.dotnet/src/Generated/Models/ChatAudioOptions.Serialization.cs b/.dotnet/src/Generated/Models/ChatAudioOptions.Serialization.cs index 8ee8a3b0b..1b6186096 100644 --- a/.dotnet/src/Generated/Models/ChatAudioOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatAudioOptions.Serialization.cs @@ -34,7 +34,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("voice") != true) { writer.WritePropertyName("voice"u8); - writer.WriteStringValue(ResponseVoice.ToString()); + writer.WriteStringValue(OutputAudioVoice.ToString()); } if (_additionalBinaryDataProperties?.ContainsKey("format") != true) { @@ -81,14 +81,14 @@ internal static ChatAudioOptions DeserializeChatAudioOptions(JsonElement element { return null; } - ChatResponseVoice responseVoice = default; + ChatOutputAudioVoice outputAudioVoice = default; ChatOutputAudioFormat outputAudioFormat = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("voice"u8)) { - responseVoice = new ChatResponseVoice(prop.Value.GetString()); + outputAudioVoice = new ChatOutputAudioVoice(prop.Value.GetString()); continue; } if (prop.NameEquals("format"u8)) @@ -101,7 +101,7 @@ internal static ChatAudioOptions DeserializeChatAudioOptions(JsonElement element additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ChatAudioOptions(responseVoice, outputAudioFormat, additionalBinaryDataProperties); + return new ChatAudioOptions(outputAudioVoice, outputAudioFormat, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/ChatAudioOptions.cs b/.dotnet/src/Generated/Models/ChatAudioOptions.cs index 129409105..18b018e26 100644 --- a/.dotnet/src/Generated/Models/ChatAudioOptions.cs +++ b/.dotnet/src/Generated/Models/ChatAudioOptions.cs @@ -11,15 +11,15 @@ public partial class ChatAudioOptions { private protected IDictionary _additionalBinaryDataProperties; - public ChatAudioOptions(ChatResponseVoice responseVoice, ChatOutputAudioFormat outputAudioFormat) + public ChatAudioOptions(ChatOutputAudioVoice outputAudioVoice, ChatOutputAudioFormat outputAudioFormat) { - ResponseVoice = responseVoice; + OutputAudioVoice = outputAudioVoice; OutputAudioFormat = outputAudioFormat; } - internal ChatAudioOptions(ChatResponseVoice responseVoice, ChatOutputAudioFormat outputAudioFormat, IDictionary additionalBinaryDataProperties) + internal ChatAudioOptions(ChatOutputAudioVoice outputAudioVoice, ChatOutputAudioFormat outputAudioFormat, IDictionary additionalBinaryDataProperties) { - ResponseVoice = responseVoice; + OutputAudioVoice = outputAudioVoice; OutputAudioFormat = outputAudioFormat; _additionalBinaryDataProperties = additionalBinaryDataProperties; } diff --git a/.dotnet/src/Generated/Models/ChatResponseAudio.Serialization.cs b/.dotnet/src/Generated/Models/ChatOutputAudio.Serialization.cs similarity index 67% rename from .dotnet/src/Generated/Models/ChatResponseAudio.Serialization.cs rename to .dotnet/src/Generated/Models/ChatOutputAudio.Serialization.cs index 40e982773..4dbb27591 100644 --- a/.dotnet/src/Generated/Models/ChatResponseAudio.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatOutputAudio.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Chat { - public partial class ChatResponseAudio : IJsonModel + public partial class ChatOutputAudio : IJsonModel { - internal ChatResponseAudio() + internal ChatOutputAudio() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ChatResponseAudio)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(ChatOutputAudio)} does not support writing '{format}' format."); } if (_additionalBinaryDataProperties?.ContainsKey("id") != true) { @@ -72,20 +72,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ChatResponseAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + ChatOutputAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual ChatResponseAudio JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual ChatOutputAudio JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ChatResponseAudio)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(ChatOutputAudio)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatResponseAudio(document.RootElement, options); + return DeserializeChatOutputAudio(document.RootElement, options); } - internal static ChatResponseAudio DeserializeChatResponseAudio(JsonElement element, ModelReaderWriterOptions options) + internal static ChatOutputAudio DeserializeChatOutputAudio(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -123,56 +123,56 @@ internal static ChatResponseAudio DeserializeChatResponseAudio(JsonElement eleme additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ChatResponseAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties); + return new ChatOutputAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(ChatResponseAudio)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(ChatOutputAudio)} does not support writing '{options.Format}' format."); } } - ChatResponseAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + ChatOutputAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual ChatResponseAudio PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual ChatOutputAudio PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeChatResponseAudio(document.RootElement, options); + return DeserializeChatOutputAudio(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(ChatResponseAudio)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(ChatOutputAudio)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(ChatResponseAudio chatResponseAudio) + public static implicit operator BinaryContent(ChatOutputAudio chatOutputAudio) { - if (chatResponseAudio == null) + if (chatOutputAudio == null) { return null; } - return BinaryContent.Create(chatResponseAudio, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(chatOutputAudio, ModelSerializationExtensions.WireOptions); } - public static explicit operator ChatResponseAudio(ClientResult result) + public static explicit operator ChatOutputAudio(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeChatResponseAudio(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeChatOutputAudio(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/ChatResponseAudio.cs b/.dotnet/src/Generated/Models/ChatOutputAudio.cs similarity index 74% rename from .dotnet/src/Generated/Models/ChatResponseAudio.cs rename to .dotnet/src/Generated/Models/ChatOutputAudio.cs index 395622cac..2971e5621 100644 --- a/.dotnet/src/Generated/Models/ChatResponseAudio.cs +++ b/.dotnet/src/Generated/Models/ChatOutputAudio.cs @@ -7,11 +7,11 @@ namespace OpenAI.Chat { - public partial class ChatResponseAudio + public partial class ChatOutputAudio { private protected IDictionary _additionalBinaryDataProperties; - internal ChatResponseAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript) + internal ChatOutputAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript) { Id = id; ExpiresAt = expiresAt; @@ -19,7 +19,7 @@ internal ChatResponseAudio(string id, DateTimeOffset expiresAt, BinaryData data, Transcript = transcript; } - internal ChatResponseAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript, IDictionary additionalBinaryDataProperties) + internal ChatOutputAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript, IDictionary additionalBinaryDataProperties) { Id = id; ExpiresAt = expiresAt; diff --git a/.dotnet/src/Generated/Models/ChatResponseAudioReference.Serialization.cs b/.dotnet/src/Generated/Models/ChatOutputAudioReference.Serialization.cs similarity index 57% rename from .dotnet/src/Generated/Models/ChatResponseAudioReference.Serialization.cs rename to .dotnet/src/Generated/Models/ChatOutputAudioReference.Serialization.cs index 57bf8862f..590c2dd88 100644 --- a/.dotnet/src/Generated/Models/ChatResponseAudioReference.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatOutputAudioReference.Serialization.cs @@ -11,13 +11,13 @@ namespace OpenAI.Chat { - public partial class ChatResponseAudioReference : IJsonModel + public partial class ChatOutputAudioReference : IJsonModel { - internal ChatResponseAudioReference() + internal ChatOutputAudioReference() { } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -26,10 +26,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ChatResponseAudioReference)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(ChatOutputAudioReference)} does not support writing '{format}' format."); } if (_additionalBinaryDataProperties?.ContainsKey("id") != true) { @@ -57,20 +57,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ChatResponseAudioReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + ChatOutputAudioReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual ChatResponseAudioReference JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual ChatOutputAudioReference JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ChatResponseAudioReference)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(ChatOutputAudioReference)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatResponseAudioReference(document.RootElement, options); + return DeserializeChatOutputAudioReference(document.RootElement, options); } - internal static ChatResponseAudioReference DeserializeChatResponseAudioReference(JsonElement element, ModelReaderWriterOptions options) + internal static ChatOutputAudioReference DeserializeChatOutputAudioReference(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -90,56 +90,56 @@ internal static ChatResponseAudioReference DeserializeChatResponseAudioReference additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ChatResponseAudioReference(id, additionalBinaryDataProperties); + return new ChatOutputAudioReference(id, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(ChatResponseAudioReference)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(ChatOutputAudioReference)} does not support writing '{options.Format}' format."); } } - ChatResponseAudioReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + ChatOutputAudioReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual ChatResponseAudioReference PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual ChatOutputAudioReference PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeChatResponseAudioReference(document.RootElement, options); + return DeserializeChatOutputAudioReference(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(ChatResponseAudioReference)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(ChatOutputAudioReference)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(ChatResponseAudioReference chatResponseAudioReference) + public static implicit operator BinaryContent(ChatOutputAudioReference chatOutputAudioReference) { - if (chatResponseAudioReference == null) + if (chatOutputAudioReference == null) { return null; } - return BinaryContent.Create(chatResponseAudioReference, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(chatOutputAudioReference, ModelSerializationExtensions.WireOptions); } - public static explicit operator ChatResponseAudioReference(ClientResult result) + public static explicit operator ChatOutputAudioReference(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeChatResponseAudioReference(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeChatOutputAudioReference(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/ChatResponseAudioReference.cs b/.dotnet/src/Generated/Models/ChatOutputAudioReference.cs similarity index 75% rename from .dotnet/src/Generated/Models/ChatResponseAudioReference.cs rename to .dotnet/src/Generated/Models/ChatOutputAudioReference.cs index 6ae6cc6fa..905a12475 100644 --- a/.dotnet/src/Generated/Models/ChatResponseAudioReference.cs +++ b/.dotnet/src/Generated/Models/ChatOutputAudioReference.cs @@ -8,18 +8,18 @@ namespace OpenAI.Chat { - public partial class ChatResponseAudioReference + public partial class ChatOutputAudioReference { private protected IDictionary _additionalBinaryDataProperties; - public ChatResponseAudioReference(string id) + public ChatOutputAudioReference(string id) { Argument.AssertNotNull(id, nameof(id)); Id = id; } - internal ChatResponseAudioReference(string id, IDictionary additionalBinaryDataProperties) + internal ChatOutputAudioReference(string id, IDictionary additionalBinaryDataProperties) { Id = id; _additionalBinaryDataProperties = additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/ChatOutputAudioVoice.cs b/.dotnet/src/Generated/Models/ChatOutputAudioVoice.cs new file mode 100644 index 000000000..8facf812d --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatOutputAudioVoice.cs @@ -0,0 +1,56 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + public readonly partial struct ChatOutputAudioVoice : IEquatable + { + private readonly string _value; + private const string AlloyValue = "alloy"; + private const string EchoValue = "echo"; + private const string FableValue = "fable"; + private const string OnyxValue = "onyx"; + private const string NovaValue = "nova"; + private const string ShimmerValue = "shimmer"; + + public ChatOutputAudioVoice(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static ChatOutputAudioVoice Alloy { get; } = new ChatOutputAudioVoice(AlloyValue); + + public static ChatOutputAudioVoice Echo { get; } = new ChatOutputAudioVoice(EchoValue); + + public static ChatOutputAudioVoice Fable { get; } = new ChatOutputAudioVoice(FableValue); + + public static ChatOutputAudioVoice Onyx { get; } = new ChatOutputAudioVoice(OnyxValue); + + public static ChatOutputAudioVoice Nova { get; } = new ChatOutputAudioVoice(NovaValue); + + public static ChatOutputAudioVoice Shimmer { get; } = new ChatOutputAudioVoice(ShimmerValue); + + public static bool operator ==(ChatOutputAudioVoice left, ChatOutputAudioVoice right) => left.Equals(right); + + public static bool operator !=(ChatOutputAudioVoice left, ChatOutputAudioVoice right) => !left.Equals(right); + + public static implicit operator ChatOutputAudioVoice(string value) => new ChatOutputAudioVoice(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatOutputAudioVoice other && Equals(other); + + public bool Equals(ChatOutputAudioVoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/ChatResponseVoice.cs b/.dotnet/src/Generated/Models/ChatResponseVoice.cs deleted file mode 100644 index d294da7cb..000000000 --- a/.dotnet/src/Generated/Models/ChatResponseVoice.cs +++ /dev/null @@ -1,56 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Chat -{ - public readonly partial struct ChatResponseVoice : IEquatable - { - private readonly string _value; - private const string AlloyValue = "alloy"; - private const string EchoValue = "echo"; - private const string FableValue = "fable"; - private const string OnyxValue = "onyx"; - private const string NovaValue = "nova"; - private const string ShimmerValue = "shimmer"; - - public ChatResponseVoice(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static ChatResponseVoice Alloy { get; } = new ChatResponseVoice(AlloyValue); - - public static ChatResponseVoice Echo { get; } = new ChatResponseVoice(EchoValue); - - public static ChatResponseVoice Fable { get; } = new ChatResponseVoice(FableValue); - - public static ChatResponseVoice Onyx { get; } = new ChatResponseVoice(OnyxValue); - - public static ChatResponseVoice Nova { get; } = new ChatResponseVoice(NovaValue); - - public static ChatResponseVoice Shimmer { get; } = new ChatResponseVoice(ShimmerValue); - - public static bool operator ==(ChatResponseVoice left, ChatResponseVoice right) => left.Equals(right); - - public static bool operator !=(ChatResponseVoice left, ChatResponseVoice right) => !left.Equals(right); - - public static implicit operator ChatResponseVoice(string value) => new ChatResponseVoice(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ChatResponseVoice other && Equals(other); - - public bool Equals(ChatResponseVoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs index c54451765..d9e55f613 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs @@ -129,7 +129,7 @@ internal static InternalChatCompletionResponseMessage DeserializeInternalChatCom } string refusal = default; IReadOnlyList toolCalls = default; - ChatResponseAudio audio = default; + ChatOutputAudio audio = default; Chat.ChatMessageRole role = default; ChatMessageContent content = default; ChatFunctionCall functionCall = default; @@ -167,7 +167,7 @@ internal static InternalChatCompletionResponseMessage DeserializeInternalChatCom audio = null; continue; } - audio = ChatResponseAudio.DeserializeChatResponseAudio(prop.Value, options); + audio = ChatOutputAudio.DeserializeChatOutputAudio(prop.Value, options); continue; } if (prop.NameEquals("role"u8)) diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs index 831039448..7b8f87e68 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionResponseMessage.cs @@ -19,7 +19,7 @@ internal InternalChatCompletionResponseMessage(string refusal, ChatMessageConten Content = content; } - internal InternalChatCompletionResponseMessage(string refusal, IReadOnlyList toolCalls, ChatResponseAudio audio, Chat.ChatMessageRole role, ChatMessageContent content, ChatFunctionCall functionCall, IDictionary additionalBinaryDataProperties) + internal InternalChatCompletionResponseMessage(string refusal, IReadOnlyList toolCalls, ChatOutputAudio audio, Chat.ChatMessageRole role, ChatMessageContent content, ChatFunctionCall functionCall, IDictionary additionalBinaryDataProperties) { Refusal = refusal; ToolCalls = toolCalls; @@ -34,7 +34,7 @@ internal InternalChatCompletionResponseMessage(string refusal, IReadOnlyList ToolCalls { get; } - public ChatResponseAudio Audio { get; } + public ChatOutputAudio Audio { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs index a67a17260..de9f8afcb 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs @@ -117,7 +117,7 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha { return null; } - StreamingChatResponseAudioUpdate audio = default; + StreamingChatOutputAudioUpdate audio = default; StreamingChatFunctionCallUpdate functionCall = default; IReadOnlyList toolCalls = default; string refusal = default; @@ -132,7 +132,7 @@ internal static InternalChatCompletionStreamResponseDelta DeserializeInternalCha { continue; } - audio = StreamingChatResponseAudioUpdate.DeserializeStreamingChatResponseAudioUpdate(prop.Value, options); + audio = StreamingChatOutputAudioUpdate.DeserializeStreamingChatOutputAudioUpdate(prop.Value, options); continue; } if (prop.NameEquals("function_call"u8)) diff --git a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs index 7882baf06..1cdd4603e 100644 --- a/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs +++ b/.dotnet/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs @@ -11,7 +11,7 @@ internal partial class InternalChatCompletionStreamResponseDelta { private protected IDictionary _additionalBinaryDataProperties; - internal InternalChatCompletionStreamResponseDelta(StreamingChatResponseAudioUpdate audio, StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, string refusal, Chat.ChatMessageRole? role, ChatMessageContent content, IDictionary additionalBinaryDataProperties) + internal InternalChatCompletionStreamResponseDelta(StreamingChatOutputAudioUpdate audio, StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, string refusal, Chat.ChatMessageRole? role, ChatMessageContent content, IDictionary additionalBinaryDataProperties) { Audio = audio; FunctionCall = functionCall; @@ -22,7 +22,7 @@ internal InternalChatCompletionStreamResponseDelta(StreamingChatResponseAudioUpd _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public StreamingChatResponseAudioUpdate Audio { get; } + public StreamingChatOutputAudioUpdate Audio { get; } public StreamingChatFunctionCallUpdate FunctionCall { get; } diff --git a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs index 19cc9073b..0003c9a54 100644 --- a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs @@ -57,7 +57,7 @@ internal static InternalFineTuneChatCompletionRequestAssistantMessage Deserializ string participantName = default; IList toolCalls = default; ChatFunctionCall functionCall = default; - ChatResponseAudioReference responseAudioReference = default; + ChatOutputAudioReference outputAudioReference = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("content"u8)) @@ -113,10 +113,10 @@ internal static InternalFineTuneChatCompletionRequestAssistantMessage Deserializ { if (prop.Value.ValueKind == JsonValueKind.Null) { - responseAudioReference = null; + outputAudioReference = null; continue; } - responseAudioReference = ChatResponseAudioReference.DeserializeChatResponseAudioReference(prop.Value, options); + outputAudioReference = ChatOutputAudioReference.DeserializeChatOutputAudioReference(prop.Value, options); continue; } if (true) @@ -133,7 +133,7 @@ internal static InternalFineTuneChatCompletionRequestAssistantMessage Deserializ participantName, toolCalls ?? new ChangeTrackingList(), functionCall, - responseAudioReference); + outputAudioReference); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs index 67114c758..0df80d87f 100644 --- a/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs +++ b/.dotnet/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs @@ -14,7 +14,7 @@ public InternalFineTuneChatCompletionRequestAssistantMessage() { } - internal InternalFineTuneChatCompletionRequestAssistantMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, ChatResponseAudioReference responseAudioReference) : base(content, role, additionalBinaryDataProperties, refusal, participantName, toolCalls, functionCall, responseAudioReference) + internal InternalFineTuneChatCompletionRequestAssistantMessage(ChatMessageContent content, Chat.ChatMessageRole role, IDictionary additionalBinaryDataProperties, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall, ChatOutputAudioReference outputAudioReference) : base(content, role, additionalBinaryDataProperties, refusal, participantName, toolCalls, functionCall, outputAudioReference) { } } diff --git a/.dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.Serialization.cs b/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.Serialization.cs similarity index 66% rename from .dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.Serialization.cs rename to .dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.Serialization.cs index 0320683ab..b855383ec 100644 --- a/.dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.Serialization.cs +++ b/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.Serialization.cs @@ -11,9 +11,9 @@ namespace OpenAI.Chat { - public partial class StreamingChatResponseAudioUpdate : IJsonModel + public partial class StreamingChatOutputAudioUpdate : IJsonModel { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -22,10 +22,10 @@ void IJsonModel.Write(Utf8JsonWriter writer, M protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(StreamingChatResponseAudioUpdate)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(StreamingChatOutputAudioUpdate)} does not support writing '{format}' format."); } if (Optional.IsDefined(Id) && _additionalBinaryDataProperties?.ContainsKey("id") != true) { @@ -68,20 +68,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - StreamingChatResponseAudioUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + StreamingChatOutputAudioUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual StreamingChatResponseAudioUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + protected virtual StreamingChatOutputAudioUpdate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(StreamingChatResponseAudioUpdate)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(StreamingChatOutputAudioUpdate)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeStreamingChatResponseAudioUpdate(document.RootElement, options); + return DeserializeStreamingChatOutputAudioUpdate(document.RootElement, options); } - internal static StreamingChatResponseAudioUpdate DeserializeStreamingChatResponseAudioUpdate(JsonElement element, ModelReaderWriterOptions options) + internal static StreamingChatOutputAudioUpdate DeserializeStreamingChatOutputAudioUpdate(JsonElement element, ModelReaderWriterOptions options) { if (element.ValueKind == JsonValueKind.Null) { @@ -127,56 +127,56 @@ internal static StreamingChatResponseAudioUpdate DeserializeStreamingChatRespons additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new StreamingChatResponseAudioUpdate(id, expiresAt, transcriptUpdate, dataUpdate, additionalBinaryDataProperties); + return new StreamingChatOutputAudioUpdate(id, expiresAt, transcriptUpdate, dataUpdate, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(StreamingChatResponseAudioUpdate)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingChatOutputAudioUpdate)} does not support writing '{options.Format}' format."); } } - StreamingChatResponseAudioUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + StreamingChatOutputAudioUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - protected virtual StreamingChatResponseAudioUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + protected virtual StreamingChatOutputAudioUpdate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": using (JsonDocument document = JsonDocument.Parse(data)) { - return DeserializeStreamingChatResponseAudioUpdate(document.RootElement, options); + return DeserializeStreamingChatOutputAudioUpdate(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(StreamingChatResponseAudioUpdate)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(StreamingChatOutputAudioUpdate)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static implicit operator BinaryContent(StreamingChatResponseAudioUpdate streamingChatResponseAudioUpdate) + public static implicit operator BinaryContent(StreamingChatOutputAudioUpdate streamingChatOutputAudioUpdate) { - if (streamingChatResponseAudioUpdate == null) + if (streamingChatOutputAudioUpdate == null) { return null; } - return BinaryContent.Create(streamingChatResponseAudioUpdate, ModelSerializationExtensions.WireOptions); + return BinaryContent.Create(streamingChatOutputAudioUpdate, ModelSerializationExtensions.WireOptions); } - public static explicit operator StreamingChatResponseAudioUpdate(ClientResult result) + public static explicit operator StreamingChatOutputAudioUpdate(ClientResult result) { using PipelineResponse response = result.GetRawResponse(); using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeStreamingChatResponseAudioUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); + return DeserializeStreamingChatOutputAudioUpdate(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.cs b/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.cs similarity index 71% rename from .dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.cs rename to .dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.cs index 31f1133bc..7864f4f30 100644 --- a/.dotnet/src/Generated/Models/StreamingChatResponseAudioUpdate.cs +++ b/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.cs @@ -7,15 +7,15 @@ namespace OpenAI.Chat { - public partial class StreamingChatResponseAudioUpdate + public partial class StreamingChatOutputAudioUpdate { private protected IDictionary _additionalBinaryDataProperties; - internal StreamingChatResponseAudioUpdate() + internal StreamingChatOutputAudioUpdate() { } - internal StreamingChatResponseAudioUpdate(string id, DateTimeOffset? expiresAt, string transcriptUpdate, BinaryData dataUpdate, IDictionary additionalBinaryDataProperties) + internal StreamingChatOutputAudioUpdate(string id, DateTimeOffset? expiresAt, string transcriptUpdate, BinaryData dataUpdate, IDictionary additionalBinaryDataProperties) { Id = id; ExpiresAt = expiresAt; diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index ff3ba3312..f37d7ed1e 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -950,7 +950,7 @@ public static UserChatMessage UserChatMessage(ChatMessageContent content = defau return new UserChatMessage(content, Chat.ChatMessageRole.User, additionalBinaryDataProperties: null, participantName); } - public static AssistantChatMessage AssistantChatMessage(ChatMessageContent content = default, string refusal = default, string participantName = default, IEnumerable toolCalls = default, ChatFunctionCall functionCall = default, ChatResponseAudioReference responseAudioReference = default) + public static AssistantChatMessage AssistantChatMessage(ChatMessageContent content = default, string refusal = default, string participantName = default, IEnumerable toolCalls = default, ChatFunctionCall functionCall = default, ChatOutputAudioReference outputAudioReference = default) { toolCalls ??= new ChangeTrackingList(); @@ -962,13 +962,13 @@ public static AssistantChatMessage AssistantChatMessage(ChatMessageContent conte participantName, toolCalls?.ToList(), functionCall, - responseAudioReference); + outputAudioReference); } - public static ChatResponseAudioReference ChatResponseAudioReference(string id = default) + public static ChatOutputAudioReference ChatOutputAudioReference(string id = default) { - return new ChatResponseAudioReference(id, additionalBinaryDataProperties: null); + return new ChatOutputAudioReference(id, additionalBinaryDataProperties: null); } public static ChatToolCall ChatToolCall(string id = default, InternalChatCompletionMessageToolCallFunction function = default, Chat.ChatToolCallKind kind = default) @@ -995,10 +995,10 @@ public static FunctionChatMessage FunctionChatMessage(ChatMessageContent content return new FunctionChatMessage(content, Chat.ChatMessageRole.Function, additionalBinaryDataProperties: null, functionName); } - public static ChatAudioOptions ChatAudioOptions(ChatResponseVoice responseVoice = default, ChatOutputAudioFormat outputAudioFormat = default) + public static ChatAudioOptions ChatAudioOptions(ChatOutputAudioVoice outputAudioVoice = default, ChatOutputAudioFormat outputAudioFormat = default) { - return new ChatAudioOptions(responseVoice, outputAudioFormat, additionalBinaryDataProperties: null); + return new ChatAudioOptions(outputAudioVoice, outputAudioFormat, additionalBinaryDataProperties: null); } public static ChatResponseFormat ChatResponseFormat(string @type = default) @@ -1035,10 +1035,10 @@ public static ChatCompletion ChatCompletion(string id = default, string model = additionalBinaryDataProperties: null); } - public static ChatResponseAudio ChatResponseAudio(string id = default, DateTimeOffset expiresAt = default, BinaryData data = default, string transcript = default) + public static ChatOutputAudio ChatOutputAudio(string id = default, DateTimeOffset expiresAt = default, BinaryData data = default, string transcript = default) { - return new ChatResponseAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties: null); + return new ChatOutputAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties: null); } public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = default, float logProbability = default, ReadOnlyMemory? utf8Bytes = default, IEnumerable topLogProbabilities = default) @@ -1259,10 +1259,10 @@ public static ChatMessageContentPart ChatMessageContentPart(Chat.ChatMessageCont serializedAdditionalRawData: null); } - public static StreamingChatResponseAudioUpdate StreamingChatResponseAudioUpdate(string id = default, DateTimeOffset? expiresAt = default, string transcriptUpdate = default, BinaryData dataUpdate = default) + public static StreamingChatOutputAudioUpdate StreamingChatOutputAudioUpdate(string id = default, DateTimeOffset? expiresAt = default, string transcriptUpdate = default, BinaryData dataUpdate = default) { - return new StreamingChatResponseAudioUpdate(id, expiresAt, transcriptUpdate, dataUpdate, additionalBinaryDataProperties: null); + return new StreamingChatOutputAudioUpdate(id, expiresAt, transcriptUpdate, dataUpdate, additionalBinaryDataProperties: null); } public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionName = default, BinaryData functionArgumentsUpdate = default) diff --git a/.dotnet/tests/Chat/ChatSmokeTests.cs b/.dotnet/tests/Chat/ChatSmokeTests.cs index 3f2e90388..ced848709 100644 --- a/.dotnet/tests/Chat/ChatSmokeTests.cs +++ b/.dotnet/tests/Chat/ChatSmokeTests.cs @@ -555,13 +555,13 @@ public void SerializeAudioThings() } """u8.ToArray())); Assert.That(message.Content, Has.Count.EqualTo(0)); - Assert.That(message.ResponseAudioReference, Is.Not.Null); - Assert.That(message.ResponseAudioReference.Id, Is.EqualTo("audio_correlated_id_1234")); + Assert.That(message.OutputAudioReference, Is.Not.Null); + Assert.That(message.OutputAudioReference.Id, Is.EqualTo("audio_correlated_id_1234")); string serializedMessage = ModelReaderWriter.Write(message).ToString(); Assert.That(serializedMessage, Does.Contain(@"""audio"":{""id"":""audio_correlated_id_1234""}")); AssistantChatMessage ordinaryTextAssistantMessage = new(["This was a message from the assistant"]); - ordinaryTextAssistantMessage.ResponseAudioReference = new("extra-audio-id"); + ordinaryTextAssistantMessage.OutputAudioReference = new("extra-audio-id"); BinaryData serializedLateAudioMessage = ModelReaderWriter.Write(ordinaryTextAssistantMessage); Assert.That(serializedLateAudioMessage.ToString(), Does.Contain("was a message")); Assert.That(serializedLateAudioMessage.ToString(), Does.Contain("extra-audio-id")); @@ -613,13 +613,13 @@ public void SerializeAudioThings() ChatCompletion audioCompletion = ModelReaderWriter.Read(rawAudioResponse); Assert.That(audioCompletion, Is.Not.Null); Assert.That(audioCompletion.Content, Has.Count.EqualTo(0)); - Assert.That(audioCompletion.ResponseAudio, Is.Not.Null); - Assert.That(audioCompletion.ResponseAudio.Id, Is.EqualTo("audio_6725224ac62481908ab55dc283289d87")); - Assert.That(audioCompletion.ResponseAudio.Data, Is.Not.Null); - Assert.That(audioCompletion.ResponseAudio.Transcript, Is.Not.Null.And.Not.Empty); + Assert.That(audioCompletion.OutputAudio, Is.Not.Null); + Assert.That(audioCompletion.OutputAudio.Id, Is.EqualTo("audio_6725224ac62481908ab55dc283289d87")); + Assert.That(audioCompletion.OutputAudio.Data, Is.Not.Null); + Assert.That(audioCompletion.OutputAudio.Transcript, Is.Not.Null.And.Not.Empty); AssistantChatMessage audioHistoryMessage = new(audioCompletion); - Assert.That(audioHistoryMessage.ResponseAudioReference?.Id, Is.EqualTo(audioCompletion.ResponseAudio.Id)); + Assert.That(audioHistoryMessage.OutputAudioReference?.Id, Is.EqualTo(audioCompletion.OutputAudio.Id)); } [Test] diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index c20df8200..c56c7fabd 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -386,24 +386,24 @@ public async Task ChatWithAudio() ChatCompletionOptions options = new() { - AudioOptions = new(ChatResponseVoice.Alloy, ChatOutputAudioFormat.Pcm16) + AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Pcm16) }; ChatCompletion completion = await client.CompleteChatAsync(messages, options); Assert.That(completion, Is.Not.Null); Assert.That(completion.Content, Has.Count.EqualTo(0)); - ChatResponseAudio responseAudio = completion.ResponseAudio; - Assert.That(responseAudio, Is.Not.Null); - Assert.That(responseAudio.Id, Is.Not.Null.And.Not.Empty); - Assert.That(responseAudio.Data, Is.Not.Null); - Assert.That(responseAudio.Transcript, Is.Not.Null.And.Not.Empty); + ChatOutputAudio outputAudio = completion.OutputAudio; + Assert.That(outputAudio, Is.Not.Null); + Assert.That(outputAudio.Id, Is.Not.Null.And.Not.Empty); + Assert.That(outputAudio.Data, Is.Not.Null); + Assert.That(outputAudio.Transcript, Is.Not.Null.And.Not.Empty); AssistantChatMessage audioHistoryMessage = ChatMessage.CreateAssistantMessage(completion); Assert.That(audioHistoryMessage, Is.InstanceOf()); Assert.That(audioHistoryMessage.Content, Has.Count.EqualTo(0)); - Assert.That(audioHistoryMessage.ResponseAudioReference?.Id, Is.EqualTo(completion.ResponseAudio.Id)); + Assert.That(audioHistoryMessage.OutputAudioReference?.Id, Is.EqualTo(completion.OutputAudio.Id)); messages.Add(audioHistoryMessage); messages.Add( @@ -416,35 +416,35 @@ public async Task ChatWithAudio() string streamedCorrelationId = null; DateTimeOffset? streamedExpiresAt = null; StringBuilder streamedTranscriptBuilder = new(); - using MemoryStream responseAudioStream = new(); + using MemoryStream outputAudioStream = new(); await foreach (StreamingChatCompletionUpdate update in client.CompleteChatStreamingAsync(messages, options)) { Assert.That(update.ContentUpdate, Has.Count.EqualTo(0)); - StreamingChatResponseAudioUpdate responseAudioUpdate = update.ResponseAudioUpdate; + StreamingChatOutputAudioUpdate outputAudioUpdate = update.OutputAudioUpdate; - if (responseAudioUpdate is not null) + if (outputAudioUpdate is not null) { - string serializedResponseAudioUpdate = ModelReaderWriter.Write(responseAudioUpdate).ToString(); - Assert.That(serializedResponseAudioUpdate, Is.Not.Null.And.Not.Empty); + string serializedOutputAudioUpdate = ModelReaderWriter.Write(outputAudioUpdate).ToString(); + Assert.That(serializedOutputAudioUpdate, Is.Not.Null.And.Not.Empty); - if (responseAudioUpdate.Id is not null) + if (outputAudioUpdate.Id is not null) { Assert.That(streamedCorrelationId, Is.Null.Or.EqualTo(streamedCorrelationId)); - streamedCorrelationId ??= responseAudioUpdate.Id; + streamedCorrelationId ??= outputAudioUpdate.Id; } - if (responseAudioUpdate.ExpiresAt.HasValue) + if (outputAudioUpdate.ExpiresAt.HasValue) { Assert.That(streamedExpiresAt.HasValue, Is.False); - streamedExpiresAt = responseAudioUpdate.ExpiresAt; + streamedExpiresAt = outputAudioUpdate.ExpiresAt; } - streamedTranscriptBuilder.Append(responseAudioUpdate.TranscriptUpdate); - responseAudioStream.Write(responseAudioUpdate.DataUpdate); + streamedTranscriptBuilder.Append(outputAudioUpdate.TranscriptUpdate); + outputAudioStream.Write(outputAudioUpdate.DataUpdate); } } Assert.That(streamedCorrelationId, Is.Not.Null.And.Not.Empty); Assert.That(streamedExpiresAt.HasValue, Is.True); Assert.That(streamedTranscriptBuilder.ToString(), Is.Not.Null.And.Not.Empty); - Assert.That(responseAudioStream.Length, Is.GreaterThan(9000)); + Assert.That(outputAudioStream.Length, Is.GreaterThan(9000)); } [Test] diff --git a/.scripts/Edit-Serialization.ps1 b/.scripts/Edit-Serialization.ps1 index 057f21e7d..0d1c06ffb 100644 --- a/.scripts/Edit-Serialization.ps1 +++ b/.scripts/Edit-Serialization.ps1 @@ -90,7 +90,7 @@ Update-In-File-With-Retry ` " participantName," " toolCalls \?\? new ChangeTrackingList\(\)," " functionCall," - " responseAudioReference\);" + " outputAudioReference\);" ) ` -ReplacePatternLines @( "// CUSTOM: Initialize Content collection property." @@ -102,7 +102,7 @@ Update-In-File-With-Retry ` " participantName," " toolCalls ?? new ChangeTrackingList()," " functionCall," - " responseAudioReference);" + " outputAudioReference);" ) ` -OutputIndentation 12 ` -RequirePresence @@ -178,7 +178,7 @@ Update-In-File-With-Retry ` " participantName," " toolCalls \?\? new ChangeTrackingList\(\)," " functionCall," - " responseAudioReference\);" + " outputAudioReference\);" ) ` -ReplacePatternLines @( "// CUSTOM: Initialize Content collection property." @@ -190,7 +190,7 @@ Update-In-File-With-Retry ` " participantName," " toolCalls ?? new ChangeTrackingList()," " functionCall," - " responseAudioReference);" + " outputAudioReference);" ) ` -OutputIndentation 12 ` -RequirePresence diff --git a/openapi3-original.yaml b/openapi3-original.yaml index 684a653b5..c229c604d 100644 --- a/openapi3-original.yaml +++ b/openapi3-original.yaml @@ -18462,7 +18462,7 @@ components: } ] } - RealtimeServerEventResponseAudioDelta: + RealtimeServerEventOutputAudioDelta: type: object description: Returned when the model-generated audio is updated. properties: @@ -18508,7 +18508,7 @@ components: "content_index": 0, "delta": "Base64EncodedAudioDelta" } - RealtimeServerEventResponseAudioDone: + RealtimeServerEventOutputAudioDone: type: object description: Returned when the model-generated audio is done. Also emitted when a Response is interrupted, incomplete, or cancelled. @@ -18550,7 +18550,7 @@ components: "output_index": 0, "content_index": 0 } - RealtimeServerEventResponseAudioTranscriptDelta: + RealtimeServerEventOutputAudioTranscriptDelta: type: object description: Returned when the model-generated transcription of audio output is updated. @@ -18597,7 +18597,7 @@ components: "content_index": 0, "delta": "Hello, how can I a" } - RealtimeServerEventResponseAudioTranscriptDone: + RealtimeServerEventOutputAudioTranscriptDone: type: object description: Returned when the model-generated transcription of audio output is done streaming. Also emitted when a Response is interrupted, incomplete, @@ -22192,16 +22192,16 @@ x-oaiMeta: key: RealtimeServerEventResponseTextDone path: - type: object - key: RealtimeServerEventResponseAudioTranscriptDelta + key: RealtimeServerEventOutputAudioTranscriptDelta path: - type: object - key: RealtimeServerEventResponseAudioTranscriptDone + key: RealtimeServerEventOutputAudioTranscriptDone path: - type: object - key: RealtimeServerEventResponseAudioDelta + key: RealtimeServerEventOutputAudioDelta path: - type: object - key: RealtimeServerEventResponseAudioDone + key: RealtimeServerEventOutputAudioDone path: - type: object key: RealtimeServerEventResponseFunctionCallArgumentsDelta From 62d716387d802892671bda8f77fbdb04f1c7e5d4 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Fri, 17 Jan 2025 11:20:54 -0800 Subject: [PATCH 12/44] PR feedback round --- .dotnet/README.md | 6 ++--- .dotnet/api/OpenAI.netstandard2.0.cs | 14 ++++++------ .../examples/Chat/Example09_ChatWithAudio.cs | 2 +- .../Chat/Example10_ChatWithAudioAsync.cs | 2 +- .../src/Custom/Chat/AssistantChatMessage.cs | 3 +-- .dotnet/src/Custom/Chat/ChatAudioOptions.cs | 6 +++-- .../src/Custom/Chat/ChatMessageContentPart.cs | 6 ++--- .dotnet/src/Custom/Chat/ChatOutputAudio.cs | 4 +++- .../src/Custom/Chat/OpenAIChatModelFactory.cs | 8 +++---- .../StreamingChatCompletionUpdate.cs | 1 + .../StreamingChatOutputAudioUpdate.cs | 4 ++-- .../Models/ChatOutputAudio.Serialization.cs | 22 +++++++++---------- .../src/Generated/Models/ChatOutputAudio.cs | 10 ++++----- ...mingChatOutputAudioUpdate.Serialization.cs | 10 ++++----- .../Models/StreamingChatOutputAudioUpdate.cs | 4 ++-- .dotnet/src/Generated/OpenAIModelFactory.cs | 8 +++---- .dotnet/tests/Chat/ChatSmokeTests.cs | 4 ++-- .dotnet/tests/Chat/ChatTests.cs | 4 ++-- 18 files changed, 60 insertions(+), 58 deletions(-) diff --git a/.dotnet/README.md b/.dotnet/README.md index 70cc32629..68bc3b970 100644 --- a/.dotnet/README.md +++ b/.dotnet/README.md @@ -376,7 +376,7 @@ byte[] audioFileRawBytes = File.ReadAllBytes(audioFilePath); BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); List messages = [ - new UserChatMessage(ChatMessageContentPart.CreateAudioPart(audioData, ChatInputAudioFormat.Wav)), + new UserChatMessage(ChatMessageContentPart.CreateInputAudioPart(audioData, ChatInputAudioFormat.Wav)), ]; // Output audio is requested by configuring AudioOptions on ChatCompletionOptions @@ -395,7 +395,7 @@ void PrintAudioContent() string outputFilePath = $"{outputAudio.Id}.mp3"; using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) { - outputFileStream.Write(outputAudio.Data); + outputFileStream.Write(outputAudio.AudioBytes); } Console.WriteLine($"Response audio written to file: {outputFilePath}"); Console.WriteLine($"Valid on followup requests until: {outputAudio.ExpiresAt}"); @@ -419,7 +419,7 @@ contain any of: - The `Id` of the streamed audio content, which can be referenced by subsequent `AssistantChatMessage` instances via `ChatAudioReference` once the streaming response is complete; this may appear across multiple `StreamingChatCompletionUpdate` instances but will always be the same value when present - The `ExpiresAt` value that describes when the `Id` will no longer be valid for use with `ChatAudioReference` in subsequent requests; this typically appears once and only once, in the final `StreamingOutputAudioUpdate` -- Incremental `TranscriptUpdate` and/or `DataUpdate` values, which can incrementally consumed and, when concatenated, form the complete audio transcript and audio output for the overall response; many of these typically appear +- Incremental `TranscriptUpdate` and/or `AudioBytesUpdate` values, which can incrementally consumed and, when concatenated, form the complete audio transcript and audio output for the overall response; many of these typically appear ## How to generate text embeddings diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 41bd69eb6..16b1d98b5 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1150,8 +1150,8 @@ public class AssistantChatMessage : ChatMessage, IJsonModel, IPersistableModel { public ChatAudioOptions(ChatOutputAudioVoice outputAudioVoice, ChatOutputAudioFormat outputAudioFormat); - public ChatOutputAudioFormat OutputAudioFormat { get; set; } - public ChatOutputAudioVoice OutputAudioVoice { get; set; } + public ChatOutputAudioFormat OutputAudioFormat { get; } + public ChatOutputAudioVoice OutputAudioVoice { get; } public static explicit operator ChatAudioOptions(ClientResult result); public static implicit operator BinaryContent(ChatAudioOptions chatAudioOptions); } @@ -1318,12 +1318,12 @@ public class ChatMessageContent : ObjectModel.Collection public ChatMessageContent(string content); } public class ChatMessageContentPart : IJsonModel, IPersistableModel { - public BinaryData AudioBytes { get; } - public ChatInputAudioFormat? AudioInputFormat { get; } public BinaryData ImageBytes { get; } public string ImageBytesMediaType { get; } public ChatImageDetailLevel? ImageDetailLevel { get; } public Uri ImageUri { get; } + public BinaryData InputAudioBytes { get; } + public ChatInputAudioFormat? InputAudioFormat { get; } public ChatMessageContentPartKind Kind { get; } public string Refusal { get; } public string Text { get; } @@ -1350,7 +1350,7 @@ public enum ChatMessageRole { Function = 4 } public class ChatOutputAudio : IJsonModel, IPersistableModel { - public BinaryData Data { get; } + public BinaryData AudioBytes { get; } public DateTimeOffset ExpiresAt { get; } public string Id { get; } public string Transcript { get; } @@ -1482,7 +1482,7 @@ public class FunctionChatMessage : ChatMessage, IJsonModel, public static class OpenAIChatModelFactory { public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatOutputAudio outputAudio = null); public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = 0, int cachedTokenCount = 0); - public static ChatOutputAudio ChatOutputAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default); + public static ChatOutputAudio ChatOutputAudio(BinaryData audioBytes, string id = null, string transcript = null, DateTimeOffset expiresAt = default); public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = 0, int audioTokenCount = 0); public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null); public static ChatTokenTopLogProbabilityDetails ChatTokenTopLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null); @@ -1520,7 +1520,7 @@ public class StreamingChatFunctionCallUpdate : IJsonModel, IPersistableModel { - public BinaryData DataUpdate { get; } + public BinaryData AudioBytesUpdate { get; } public DateTimeOffset? ExpiresAt { get; } public string Id { get; } public string TranscriptUpdate { get; } diff --git a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs index 821b2cf30..814e6f4ed 100644 --- a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs +++ b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs @@ -39,7 +39,7 @@ void PrintAudioContent() string outputFilePath = $"{outputAudio.Id}.mp3"; using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) { - outputFileStream.Write(outputAudio.Data); + outputFileStream.Write(outputAudio.AudioBytes); } Console.WriteLine($"Response audio written to file: {outputFilePath}"); Console.WriteLine($"Valid on followup requests until: {outputAudio.ExpiresAt}"); diff --git a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs index 34ad5e7d7..1348826a8 100644 --- a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs +++ b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs @@ -40,7 +40,7 @@ async Task PrintAudioContentAsync() string outputFilePath = $"{outputAudio.Id}.mp3"; using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) { - await outputFileStream.WriteAsync(outputAudio.Data); + await outputFileStream.WriteAsync(outputAudio.AudioBytes); } Console.WriteLine($"Response audio written to file: {outputFilePath}"); Console.WriteLine($"Valid on followup requests until: {outputAudio.ExpiresAt}"); diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.cs b/.dotnet/src/Custom/Chat/AssistantChatMessage.cs index 77d31bff5..99d83eec3 100644 --- a/.dotnet/src/Custom/Chat/AssistantChatMessage.cs +++ b/.dotnet/src/Custom/Chat/AssistantChatMessage.cs @@ -130,7 +130,6 @@ public AssistantChatMessage(ChatCompletion chatCompletion) { ToolCalls.Add(toolCall); } - // Note: The internal Audio property will be populated via reprojected Content upon serialization. } // CUSTOM: Renamed. @@ -148,7 +147,7 @@ public AssistantChatMessage(ChatCompletion chatCompletion) [Obsolete($"This property is obsolete. Please use {nameof(ToolCalls)} instead.")] public ChatFunctionCall FunctionCall { get; set; } - // CUSTOM: Made internal for reprojected representation within the content collection. + // CUSTOM: Renamed. [CodeGenMember("Audio")] public ChatOutputAudioReference OutputAudioReference { get; set; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatAudioOptions.cs b/.dotnet/src/Custom/Chat/ChatAudioOptions.cs index 5c07bfd4a..03b4f6a51 100644 --- a/.dotnet/src/Custom/Chat/ChatAudioOptions.cs +++ b/.dotnet/src/Custom/Chat/ChatAudioOptions.cs @@ -14,15 +14,17 @@ namespace OpenAI.Chat; [CodeGenModel("CreateChatCompletionRequestAudio")] public partial class ChatAudioOptions { + // CUSTOM: Renamed. /// /// Gets or sets the voice model that the response should use to synthesize audio. /// [CodeGenMember("Voice")] - public ChatOutputAudioVoice OutputAudioVoice { get; set; } + public ChatOutputAudioVoice OutputAudioVoice { get; } + // CUSTOM: Renamed. /// /// Specifies the output format desired for synthesized audio. /// [CodeGenMember("Format")] - public ChatOutputAudioFormat OutputAudioFormat { get; set; } + public ChatOutputAudioFormat OutputAudioFormat { get; } } diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs index 8f144a196..73c7d2bb0 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs @@ -87,16 +87,16 @@ internal ChatMessageContentPart( /// Present when is . The content part /// represents user role audio input. /// - public BinaryData AudioBytes => _inputAudio?.Data; + public BinaryData InputAudioBytes => _inputAudio?.Data; /// - /// The encoding format that the audio data provided in should be interpreted with. + /// The encoding format that the audio data provided in should be interpreted with. /// /// /// Present when is . The content part /// represents user role audio input. /// - public ChatInputAudioFormat? AudioInputFormat => _inputAudio?.Format; + public ChatInputAudioFormat? InputAudioFormat => _inputAudio?.Format; // CUSTOM: Spread. /// diff --git a/.dotnet/src/Custom/Chat/ChatOutputAudio.cs b/.dotnet/src/Custom/Chat/ChatOutputAudio.cs index f8ddfa934..1c151bc93 100644 --- a/.dotnet/src/Custom/Chat/ChatOutputAudio.cs +++ b/.dotnet/src/Custom/Chat/ChatOutputAudio.cs @@ -10,5 +10,7 @@ namespace OpenAI.Chat; [CodeGenModel("ChatCompletionResponseMessageAudio")] public partial class ChatOutputAudio { - + // CUSTOM: Renamed. + [CodeGenMember("Data")] + public BinaryData AudioBytes { get; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs index 1493096b5..a9391caf0 100644 --- a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs +++ b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -121,13 +121,13 @@ public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reason return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, additionalBinaryDataProperties: null); } - public static ChatOutputAudio ChatOutputAudio(BinaryData data, string id = null, string transcript = null, DateTimeOffset expiresAt = default) + public static ChatOutputAudio ChatOutputAudio(BinaryData audioBytes, string id = null, string transcript = null, DateTimeOffset expiresAt = default) { return new ChatOutputAudio( id, expiresAt, - data, transcript, + audioBytes, additionalBinaryDataProperties: null); } @@ -212,13 +212,13 @@ public static StreamingChatOutputAudioUpdate StreamingChatOutputAudioUpdate( string id = null, DateTimeOffset? expiresAt = null, string transcriptUpdate = null, - BinaryData dataUpdate = null) + BinaryData audioBytesUpdate = null) { return new StreamingChatOutputAudioUpdate( id, expiresAt, transcriptUpdate, - dataUpdate, + audioBytesUpdate, additionalBinaryDataProperties: null); } diff --git a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs index 28581f162..93d392013 100644 --- a/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs +++ b/.dotnet/src/Custom/Chat/Streaming/StreamingChatCompletionUpdate.cs @@ -110,6 +110,7 @@ public IReadOnlyList ToolCallUpdates [Obsolete($"This property is obsolete. Please use {nameof(ToolCallUpdates)} instead.")] public StreamingChatFunctionCallUpdate FunctionCallUpdate => InternalChoiceDelta?.FunctionCall; + // CUSTOM: Flattened choice delta property. /// /// Incremental output audio generated by the model. Only expected when output audio has been requested via providing /// to and only available with diff --git a/.dotnet/src/Custom/Chat/Streaming/StreamingChatOutputAudioUpdate.cs b/.dotnet/src/Custom/Chat/Streaming/StreamingChatOutputAudioUpdate.cs index a7a468b3e..ef1058f99 100644 --- a/.dotnet/src/Custom/Chat/Streaming/StreamingChatOutputAudioUpdate.cs +++ b/.dotnet/src/Custom/Chat/Streaming/StreamingChatOutputAudioUpdate.cs @@ -19,10 +19,10 @@ public partial class StreamingChatOutputAudioUpdate // CUSTOM: Renamed for clarity of incremental data availability while streaming. /// - /// The next, incremental response audio data chunk from the streaming response. payloads + /// The next, incremental response audio data chunk from the streaming response. payloads /// across all received instances should be concatenated to form the /// full response audio. /// [CodeGenMember("Data")] - public BinaryData DataUpdate { get; } + public BinaryData AudioBytesUpdate { get; } } diff --git a/.dotnet/src/Generated/Models/ChatOutputAudio.Serialization.cs b/.dotnet/src/Generated/Models/ChatOutputAudio.Serialization.cs index 4dbb27591..42f31f886 100644 --- a/.dotnet/src/Generated/Models/ChatOutputAudio.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatOutputAudio.Serialization.cs @@ -41,16 +41,16 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("expires_at"u8); writer.WriteNumberValue(ExpiresAt, "U"); } - if (_additionalBinaryDataProperties?.ContainsKey("data") != true) - { - writer.WritePropertyName("data"u8); - writer.WriteBase64StringValue(Data.ToArray(), "D"); - } if (_additionalBinaryDataProperties?.ContainsKey("transcript") != true) { writer.WritePropertyName("transcript"u8); writer.WriteStringValue(Transcript); } + if (_additionalBinaryDataProperties?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(AudioBytes.ToArray(), "D"); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -93,8 +93,8 @@ internal static ChatOutputAudio DeserializeChatOutputAudio(JsonElement element, } string id = default; DateTimeOffset expiresAt = default; - BinaryData data = default; string transcript = default; + BinaryData audioBytes = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -108,14 +108,14 @@ internal static ChatOutputAudio DeserializeChatOutputAudio(JsonElement element, expiresAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); continue; } - if (prop.NameEquals("data"u8)) + if (prop.NameEquals("transcript"u8)) { - data = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); + transcript = prop.Value.GetString(); continue; } - if (prop.NameEquals("transcript"u8)) + if (prop.NameEquals("data"u8)) { - transcript = prop.Value.GetString(); + audioBytes = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); continue; } if (true) @@ -123,7 +123,7 @@ internal static ChatOutputAudio DeserializeChatOutputAudio(JsonElement element, additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ChatOutputAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties); + return new ChatOutputAudio(id, expiresAt, transcript, audioBytes, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/ChatOutputAudio.cs b/.dotnet/src/Generated/Models/ChatOutputAudio.cs index 2971e5621..cf03c955a 100644 --- a/.dotnet/src/Generated/Models/ChatOutputAudio.cs +++ b/.dotnet/src/Generated/Models/ChatOutputAudio.cs @@ -11,20 +11,20 @@ public partial class ChatOutputAudio { private protected IDictionary _additionalBinaryDataProperties; - internal ChatOutputAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript) + internal ChatOutputAudio(string id, DateTimeOffset expiresAt, string transcript, BinaryData audioBytes) { Id = id; ExpiresAt = expiresAt; - Data = data; Transcript = transcript; + AudioBytes = audioBytes; } - internal ChatOutputAudio(string id, DateTimeOffset expiresAt, BinaryData data, string transcript, IDictionary additionalBinaryDataProperties) + internal ChatOutputAudio(string id, DateTimeOffset expiresAt, string transcript, BinaryData audioBytes, IDictionary additionalBinaryDataProperties) { Id = id; ExpiresAt = expiresAt; - Data = data; Transcript = transcript; + AudioBytes = audioBytes; _additionalBinaryDataProperties = additionalBinaryDataProperties; } @@ -32,8 +32,6 @@ internal ChatOutputAudio(string id, DateTimeOffset expiresAt, BinaryData data, s public DateTimeOffset ExpiresAt { get; } - public BinaryData Data { get; } - public string Transcript { get; } internal IDictionary SerializedAdditionalRawData diff --git a/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.Serialization.cs b/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.Serialization.cs index b855383ec..080cfa4c5 100644 --- a/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.Serialization.cs +++ b/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.Serialization.cs @@ -42,10 +42,10 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("transcript"u8); writer.WriteStringValue(TranscriptUpdate); } - if (Optional.IsDefined(DataUpdate) && _additionalBinaryDataProperties?.ContainsKey("data") != true) + if (Optional.IsDefined(AudioBytesUpdate) && _additionalBinaryDataProperties?.ContainsKey("data") != true) { writer.WritePropertyName("data"u8); - writer.WriteBase64StringValue(DataUpdate.ToArray(), "D"); + writer.WriteBase64StringValue(AudioBytesUpdate.ToArray(), "D"); } if (true && _additionalBinaryDataProperties != null) { @@ -90,7 +90,7 @@ internal static StreamingChatOutputAudioUpdate DeserializeStreamingChatOutputAud string id = default; DateTimeOffset? expiresAt = default; string transcriptUpdate = default; - BinaryData dataUpdate = default; + BinaryData audioBytesUpdate = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -119,7 +119,7 @@ internal static StreamingChatOutputAudioUpdate DeserializeStreamingChatOutputAud { continue; } - dataUpdate = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); + audioBytesUpdate = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); continue; } if (true) @@ -127,7 +127,7 @@ internal static StreamingChatOutputAudioUpdate DeserializeStreamingChatOutputAud additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new StreamingChatOutputAudioUpdate(id, expiresAt, transcriptUpdate, dataUpdate, additionalBinaryDataProperties); + return new StreamingChatOutputAudioUpdate(id, expiresAt, transcriptUpdate, audioBytesUpdate, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.cs b/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.cs index 7864f4f30..9abebcebd 100644 --- a/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.cs +++ b/.dotnet/src/Generated/Models/StreamingChatOutputAudioUpdate.cs @@ -15,12 +15,12 @@ internal StreamingChatOutputAudioUpdate() { } - internal StreamingChatOutputAudioUpdate(string id, DateTimeOffset? expiresAt, string transcriptUpdate, BinaryData dataUpdate, IDictionary additionalBinaryDataProperties) + internal StreamingChatOutputAudioUpdate(string id, DateTimeOffset? expiresAt, string transcriptUpdate, BinaryData audioBytesUpdate, IDictionary additionalBinaryDataProperties) { Id = id; ExpiresAt = expiresAt; TranscriptUpdate = transcriptUpdate; - DataUpdate = dataUpdate; + AudioBytesUpdate = audioBytesUpdate; _additionalBinaryDataProperties = additionalBinaryDataProperties; } diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index f37d7ed1e..bb173a37f 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -1035,10 +1035,10 @@ public static ChatCompletion ChatCompletion(string id = default, string model = additionalBinaryDataProperties: null); } - public static ChatOutputAudio ChatOutputAudio(string id = default, DateTimeOffset expiresAt = default, BinaryData data = default, string transcript = default) + public static ChatOutputAudio ChatOutputAudio(string id = default, DateTimeOffset expiresAt = default, string transcript = default, BinaryData audioBytes = default) { - return new ChatOutputAudio(id, expiresAt, data, transcript, additionalBinaryDataProperties: null); + return new ChatOutputAudio(id, expiresAt, transcript, audioBytes, additionalBinaryDataProperties: null); } public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = default, float logProbability = default, ReadOnlyMemory? utf8Bytes = default, IEnumerable topLogProbabilities = default) @@ -1259,10 +1259,10 @@ public static ChatMessageContentPart ChatMessageContentPart(Chat.ChatMessageCont serializedAdditionalRawData: null); } - public static StreamingChatOutputAudioUpdate StreamingChatOutputAudioUpdate(string id = default, DateTimeOffset? expiresAt = default, string transcriptUpdate = default, BinaryData dataUpdate = default) + public static StreamingChatOutputAudioUpdate StreamingChatOutputAudioUpdate(string id = default, DateTimeOffset? expiresAt = default, string transcriptUpdate = default, BinaryData audioBytesUpdate = default) { - return new StreamingChatOutputAudioUpdate(id, expiresAt, transcriptUpdate, dataUpdate, additionalBinaryDataProperties: null); + return new StreamingChatOutputAudioUpdate(id, expiresAt, transcriptUpdate, audioBytesUpdate, additionalBinaryDataProperties: null); } public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionName = default, BinaryData functionArgumentsUpdate = default) diff --git a/.dotnet/tests/Chat/ChatSmokeTests.cs b/.dotnet/tests/Chat/ChatSmokeTests.cs index ced848709..9b82ba18c 100644 --- a/.dotnet/tests/Chat/ChatSmokeTests.cs +++ b/.dotnet/tests/Chat/ChatSmokeTests.cs @@ -544,7 +544,7 @@ public void SerializeAudioThings() BinaryData serializedInputAudioContentPart = ModelReaderWriter.Write(inputAudioContentPart); Assert.That(serializedInputAudioContentPart.ToString(), Does.Contain(@"""format"":""mp3""")); ChatMessageContentPart deserializedInputAudioContentPart = ModelReaderWriter.Read(serializedInputAudioContentPart); - Assert.That(deserializedInputAudioContentPart.AudioBytes.ToArray()[1], Is.EqualTo(0x2)); + Assert.That(deserializedInputAudioContentPart.InputAudioBytes.ToArray()[1], Is.EqualTo(0x2)); AssistantChatMessage message = ModelReaderWriter.Read(BinaryData.FromBytes(""" { @@ -615,7 +615,7 @@ public void SerializeAudioThings() Assert.That(audioCompletion.Content, Has.Count.EqualTo(0)); Assert.That(audioCompletion.OutputAudio, Is.Not.Null); Assert.That(audioCompletion.OutputAudio.Id, Is.EqualTo("audio_6725224ac62481908ab55dc283289d87")); - Assert.That(audioCompletion.OutputAudio.Data, Is.Not.Null); + Assert.That(audioCompletion.OutputAudio.AudioBytes, Is.Not.Null); Assert.That(audioCompletion.OutputAudio.Transcript, Is.Not.Null.And.Not.Empty); AssistantChatMessage audioHistoryMessage = new(audioCompletion); diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index c56c7fabd..2780ca2fe 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -396,7 +396,7 @@ public async Task ChatWithAudio() ChatOutputAudio outputAudio = completion.OutputAudio; Assert.That(outputAudio, Is.Not.Null); Assert.That(outputAudio.Id, Is.Not.Null.And.Not.Empty); - Assert.That(outputAudio.Data, Is.Not.Null); + Assert.That(outputAudio.AudioBytes, Is.Not.Null); Assert.That(outputAudio.Transcript, Is.Not.Null.And.Not.Empty); AssistantChatMessage audioHistoryMessage = ChatMessage.CreateAssistantMessage(completion); @@ -438,7 +438,7 @@ public async Task ChatWithAudio() streamedExpiresAt = outputAudioUpdate.ExpiresAt; } streamedTranscriptBuilder.Append(outputAudioUpdate.TranscriptUpdate); - outputAudioStream.Write(outputAudioUpdate.DataUpdate); + outputAudioStream.Write(outputAudioUpdate.AudioBytesUpdate); } } Assert.That(streamedCorrelationId, Is.Not.Null.And.Not.Empty); From a57d3038b07ed14d34d50f2831c2a0f72a7e96c3 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Fri, 17 Jan 2025 12:12:01 -0800 Subject: [PATCH 13/44] Expose and require ContentModalities for Chat --- .dotnet/CHANGELOG.md | 2 +- .dotnet/README.md | 1 + .dotnet/api/OpenAI.netstandard2.0.cs | 8 +++- .../examples/Chat/Example09_ChatWithAudio.cs | 1 + .../Chat/Example10_ChatWithAudioAsync.cs | 1 + .../src/Custom/Chat/ChatCompletionOptions.cs | 6 +++ .../ChatContentModalities.Serialization.cs | 37 +++++++++++++++++++ .../src/Custom/Chat/ChatContentModalities.cs | 10 +++++ .../src/Custom/Chat/OpenAIChatModelFactory.cs | 2 +- .dotnet/tests/Chat/ChatTests.cs | 1 + 10 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 .dotnet/src/Custom/Chat/ChatContentModalities.Serialization.cs create mode 100644 .dotnet/src/Custom/Chat/ChatContentModalities.cs diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index ed1e12043..e54db88ae 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -5,7 +5,7 @@ ### Features added - Chat completion now supports audio input and output! - - To configure a chat completion to request audio output using the `gpt-4o-audio-preview` model, create a `ChatAudioOptions` instance and provide it on `ChatCompletionOptions.AudioOptions`. + - To configure a chat completion to request audio output using the `gpt-4o-audio-preview` model, use `ChatContentModalities.Text | ChatContentModalities.Audio` as the value for `ChatCompletionOptions.ContentModalities` and create a `ChatAudioOptions` instance for `ChatCompletionOptions.AudioOptions`. - Input chat audio is provided to `UserChatMessage` instances using `ChatContentPart.CreateInputAudioPart()` - Output chat audio is provided on the `OutputAudio` property of `ChatCompletion` - References to prior assistant audio are provided via `OutputAudioReference` instances on the `AudioReference` property of `AssistantChatMessage`; `AssistantChatMessage(chatCompletion)` will automatically handle this, too diff --git a/.dotnet/README.md b/.dotnet/README.md index 68bc3b970..9d149f38f 100644 --- a/.dotnet/README.md +++ b/.dotnet/README.md @@ -382,6 +382,7 @@ List messages = // Output audio is requested by configuring AudioOptions on ChatCompletionOptions ChatCompletionOptions options = new() { + ContentModalities = ChatContentModalities.Text | ChatContentModalities.Audio, AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), }; diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 16b1d98b5..271bb8feb 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1197,6 +1197,7 @@ public class ChatCompletion : IJsonModel, IPersistableModel, IPersistableModel { public bool? AllowParallelToolCalls { get; set; } public ChatAudioOptions AudioOptions { get; set; } + public ChatContentModalities ContentModalities { get; set; } public string EndUserId { get; set; } public float? FrequencyPenalty { get; set; } [Obsolete("This property is obsolete. Please use ToolChoice instead.")] @@ -1220,6 +1221,11 @@ public class ChatCompletionOptions : IJsonModel, IPersist public static explicit operator ChatCompletionOptions(ClientResult result); public static implicit operator BinaryContent(ChatCompletionOptions chatCompletionOptions); } + [Flags] + public enum ChatContentModalities { + Text = 1, + Audio = 2 + } public enum ChatFinishReason { Stop = 0, Length = 1, @@ -1490,7 +1496,7 @@ public static class OpenAIChatModelFactory { public static StreamingChatCompletionUpdate StreamingChatCompletionUpdate(string completionId = null, ChatMessageContent contentUpdate = null, StreamingChatFunctionCallUpdate functionCallUpdate = null, IEnumerable toolCallUpdates = null, ChatMessageRole? role = null, string refusalUpdate = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, ChatFinishReason? finishReason = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, StreamingChatOutputAudioUpdate outputAudioUpdate = null); [Obsolete("This class is obsolete. Please use StreamingChatToolCallUpdate instead.")] public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionName = null, BinaryData functionArgumentsUpdate = null); - public static StreamingChatOutputAudioUpdate StreamingChatOutputAudioUpdate(string id = null, DateTimeOffset? expiresAt = null, string transcriptUpdate = null, BinaryData dataUpdate = null); + public static StreamingChatOutputAudioUpdate StreamingChatOutputAudioUpdate(string id = null, DateTimeOffset? expiresAt = null, string transcriptUpdate = null, BinaryData audioBytesUpdate = null); public static StreamingChatToolCallUpdate StreamingChatToolCallUpdate(int index = 0, string toolCallId = null, ChatToolCallKind kind = ChatToolCallKind.Function, string functionName = null, BinaryData functionArgumentsUpdate = null); } public class StreamingChatCompletionUpdate : IJsonModel, IPersistableModel { diff --git a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs index 814e6f4ed..df9c5c074 100644 --- a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs +++ b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs @@ -26,6 +26,7 @@ public void Example09_ChatWithAudio() // Output audio is requested by configuring AudioOptions on ChatCompletionOptions ChatCompletionOptions options = new() { + ContentModalities = ChatContentModalities.Text | ChatContentModalities.Audio, AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), }; diff --git a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs index 1348826a8..e4ad2d7e6 100644 --- a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs +++ b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs @@ -27,6 +27,7 @@ public async Task Example09_ChatWithAudioAsync() // Output audio is requested by configuring AudioOptions on ChatCompletionOptions ChatCompletionOptions options = new() { + ContentModalities = ChatContentModalities.Text | ChatContentModalities.Audio, AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), }; diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs index 78788dda5..cdd1f9452 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs @@ -181,6 +181,12 @@ public ChatCompletionOptions() [CodeGenMember("Modalities")] private IList _internalModalities = new ChangeTrackingList(); + public ChatContentModalities ContentModalities + { + get => ChatContentModalitiesExtensions.FromInternalModalities(_internalModalities); + set => _internalModalities = value.ToInternalModalities(); + } + // CUSTOM: supplemented with custom setter to internally enable audio output via modalities. [CodeGenMember("Audio")] private ChatAudioOptions _audioOptions; diff --git a/.dotnet/src/Custom/Chat/ChatContentModalities.Serialization.cs b/.dotnet/src/Custom/Chat/ChatContentModalities.Serialization.cs new file mode 100644 index 000000000..1e90cb9ac --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatContentModalities.Serialization.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; + +namespace OpenAI.Chat; + +internal static partial class ChatContentModalitiesExtensions +{ + internal static IList ToInternalModalities(this ChatContentModalities modalities) + { + List internalModalities = []; + if (modalities.HasFlag(ChatContentModalities.Text)) + { + internalModalities.Add(InternalCreateChatCompletionRequestModality.Text); + } + if (modalities.HasFlag(ChatContentModalities.Audio)) + { + internalModalities.Add(InternalCreateChatCompletionRequestModality.Audio); + } + return internalModalities; + } + + internal static ChatContentModalities FromInternalModalities(IEnumerable internalModalities) + { + ChatContentModalities result = 0; + foreach (InternalCreateChatCompletionRequestModality internalModality in internalModalities ?? []) + { + if (internalModality == InternalCreateChatCompletionRequestModality.Text) + { + result |= ChatContentModalities.Text; + } + else if (internalModality == InternalCreateChatCompletionRequestModality.Audio) + { + result |= ChatContentModalities.Audio; + } + } + return result; + } +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatContentModalities.cs b/.dotnet/src/Custom/Chat/ChatContentModalities.cs new file mode 100644 index 000000000..d3ed68c92 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatContentModalities.cs @@ -0,0 +1,10 @@ +using System; + +namespace OpenAI.Chat; + +[Flags] +public enum ChatContentModalities : int +{ + Text = 1 << 0, + Audio = 1 << 1, +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs index a9391caf0..d31de831b 100644 --- a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs +++ b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -206,7 +206,7 @@ public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(st /// /// /// - /// + /// /// public static StreamingChatOutputAudioUpdate StreamingChatOutputAudioUpdate( string id = null, diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index 2780ca2fe..5d4d66759 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -386,6 +386,7 @@ public async Task ChatWithAudio() ChatCompletionOptions options = new() { + ContentModalities = ChatContentModalities.Text | ChatContentModalities.Audio, AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Pcm16) }; From 046648cc7761148f33d000e93d7cbbd47371e2d9 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Fri, 17 Jan 2025 16:38:10 -0800 Subject: [PATCH 14/44] PR feedback --- .dotnet/CHANGELOG.md | 2 +- .dotnet/README.md | 12 +++++---- .dotnet/api/OpenAI.netstandard2.0.cs | 14 +++++----- .../examples/Chat/Example09_ChatWithAudio.cs | 5 ++-- .../Chat/Example10_ChatWithAudioAsync.cs | 7 ++--- .../src/Custom/Chat/ChatCompletionOptions.cs | 12 +++++++-- .../src/Custom/Chat/ChatContentModalities.cs | 10 ------- .../src/Custom/Chat/ChatMessageContentPart.cs | 10 +++---- ...> ChatResponseModalities.Serialization.cs} | 14 +++++----- .../src/Custom/Chat/ChatResponseModalities.cs | 26 +++++++++++++++++++ .dotnet/tests/Chat/ChatTests.cs | 2 +- 11 files changed, 71 insertions(+), 43 deletions(-) delete mode 100644 .dotnet/src/Custom/Chat/ChatContentModalities.cs rename .dotnet/src/Custom/Chat/{ChatContentModalities.Serialization.cs => ChatResponseModalities.Serialization.cs} (65%) create mode 100644 .dotnet/src/Custom/Chat/ChatResponseModalities.cs diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index e54db88ae..7dacb2b6b 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -5,7 +5,7 @@ ### Features added - Chat completion now supports audio input and output! - - To configure a chat completion to request audio output using the `gpt-4o-audio-preview` model, use `ChatContentModalities.Text | ChatContentModalities.Audio` as the value for `ChatCompletionOptions.ContentModalities` and create a `ChatAudioOptions` instance for `ChatCompletionOptions.AudioOptions`. + - To configure a chat completion to request audio output using the `gpt-4o-audio-preview` model, use `ChatResponseModalities.Text | ChatResponseModalities.Audio` as the value for `ChatCompletionOptions.ResponseModalities` and create a `ChatAudioOptions` instance for `ChatCompletionOptions.AudioOptions`. - Input chat audio is provided to `UserChatMessage` instances using `ChatContentPart.CreateInputAudioPart()` - Output chat audio is provided on the `OutputAudio` property of `ChatCompletion` - References to prior assistant audio are provided via `OutputAudioReference` instances on the `AudioReference` property of `AssistantChatMessage`; `AssistantChatMessage(chatCompletion)` will automatically handle this, too diff --git a/.dotnet/README.md b/.dotnet/README.md index 9d149f38f..10a815604 100644 --- a/.dotnet/README.md +++ b/.dotnet/README.md @@ -371,7 +371,7 @@ This example demonstrates: ChatClient client = new("gpt-4o-audio-preview", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); // Input audio is provided to a request by adding an audio content part to a user message -string audioFilePath = Path.Combine("Assets", "whats_the_weather_pcm16_24khz_mono.wav"); +string audioFilePath = Path.Combine("Assets", "realtime_whats_the_weather_pcm16_24khz_mono.wav"); byte[] audioFileRawBytes = File.ReadAllBytes(audioFilePath); BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); List messages = @@ -379,10 +379,11 @@ List messages = new UserChatMessage(ChatMessageContentPart.CreateInputAudioPart(audioData, ChatInputAudioFormat.Wav)), ]; -// Output audio is requested by configuring AudioOptions on ChatCompletionOptions +// Output audio is requested by configuring ChatCompletionOptions to include the appropriate +// ResponseModalities values and corresponding AudioOptions. ChatCompletionOptions options = new() { - ContentModalities = ChatContentModalities.Text | ChatContentModalities.Audio, + ResponseModalities = ChatResponseModalities.Text | ChatResponseModalities.Audio, AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), }; @@ -405,8 +406,9 @@ void PrintAudioContent() PrintAudioContent(); -// To refer to past audio output, create an assistant message from the earlier ChatCompletion or instantiate a -// ChatOutputAudioReference(string) from the .Id of the completion's .OutputAudio property. +// To refer to past audio output, create an assistant message from the earlier ChatCompletion, use the earlier +// response content part, or use ChatMessageContentPart.CreateAudioPart(string) to manually instantiate a part. + messages.Add(new AssistantChatMessage(completion)); messages.Add("Can you say that like a pirate?"); diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 271bb8feb..8cddc7655 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1197,7 +1197,6 @@ public class ChatCompletion : IJsonModel, IPersistableModel, IPersistableModel { public bool? AllowParallelToolCalls { get; set; } public ChatAudioOptions AudioOptions { get; set; } - public ChatContentModalities ContentModalities { get; set; } public string EndUserId { get; set; } public float? FrequencyPenalty { get; set; } [Obsolete("This property is obsolete. Please use ToolChoice instead.")] @@ -1210,6 +1209,7 @@ public class ChatCompletionOptions : IJsonModel, IPersist public IDictionary Metadata { get; } public float? PresencePenalty { get; set; } public ChatResponseFormat ResponseFormat { get; set; } + public ChatResponseModalities? ResponseModalities { get; set; } public long? Seed { get; set; } public IList StopSequences { get; } public bool? StoredOutputEnabled { get; set; } @@ -1221,11 +1221,6 @@ public class ChatCompletionOptions : IJsonModel, IPersist public static explicit operator ChatCompletionOptions(ClientResult result); public static implicit operator BinaryContent(ChatCompletionOptions chatCompletionOptions); } - [Flags] - public enum ChatContentModalities { - Text = 1, - Audio = 2 - } public enum ChatFinishReason { Stop = 0, Length = 1, @@ -1335,7 +1330,7 @@ public class ChatMessageContentPart : IJsonModel, IPersi public string Text { get; } public static ChatMessageContentPart CreateImagePart(BinaryData imageBytes, string imageBytesMediaType, ChatImageDetailLevel? imageDetailLevel = null); public static ChatMessageContentPart CreateImagePart(Uri imageUri, ChatImageDetailLevel? imageDetailLevel = null); - public static ChatMessageContentPart CreateInputAudioPart(BinaryData audioBytes, ChatInputAudioFormat audioFormat); + public static ChatMessageContentPart CreateInputAudioPart(BinaryData inputAudioBytes, ChatInputAudioFormat inputAudioFormat); public static ChatMessageContentPart CreateRefusalPart(string refusal); public static ChatMessageContentPart CreateTextPart(string text); public static explicit operator ChatMessageContentPart(ClientResult result); @@ -1417,6 +1412,11 @@ public class ChatResponseFormat : IJsonModel, IPersistableMo public static explicit operator ChatResponseFormat(ClientResult result); public static implicit operator BinaryContent(ChatResponseFormat chatResponseFormat); } + [Flags] + public enum ChatResponseModalities { + Text = 1, + Audio = 2 + } public class ChatTokenLogProbabilityDetails : IJsonModel, IPersistableModel { public float LogProbability { get; } public string Token { get; } diff --git a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs index df9c5c074..b18ad79e2 100644 --- a/.dotnet/examples/Chat/Example09_ChatWithAudio.cs +++ b/.dotnet/examples/Chat/Example09_ChatWithAudio.cs @@ -23,10 +23,11 @@ public void Example09_ChatWithAudio() new UserChatMessage(ChatMessageContentPart.CreateInputAudioPart(audioData, ChatInputAudioFormat.Wav)), ]; - // Output audio is requested by configuring AudioOptions on ChatCompletionOptions + // Output audio is requested by configuring ChatCompletionOptions to include the appropriate + // ResponseModalities values and corresponding AudioOptions. ChatCompletionOptions options = new() { - ContentModalities = ChatContentModalities.Text | ChatContentModalities.Audio, + ResponseModalities = ChatResponseModalities.Text | ChatResponseModalities.Audio, AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), }; diff --git a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs index e4ad2d7e6..fe6f2cf67 100644 --- a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs +++ b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs @@ -10,7 +10,7 @@ namespace OpenAI.Examples; public partial class ChatExamples { [Test] - public async Task Example09_ChatWithAudioAsync() + public async Task Example10_ChatWithAudioAsync() { // Chat audio input and output is only supported on specific models, beginning with gpt-4o-audio-preview ChatClient client = new("gpt-4o-audio-preview", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); @@ -24,10 +24,11 @@ public async Task Example09_ChatWithAudioAsync() new UserChatMessage(ChatMessageContentPart.CreateInputAudioPart(audioData, ChatInputAudioFormat.Wav)), ]; - // Output audio is requested by configuring AudioOptions on ChatCompletionOptions + // Output audio is requested by configuring ChatCompletionOptions to include the appropriate + // ResponseModalities values and corresponding AudioOptions. ChatCompletionOptions options = new() { - ContentModalities = ChatContentModalities.Text | ChatContentModalities.Audio, + ResponseModalities = ChatResponseModalities.Text | ChatResponseModalities.Audio, AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), }; diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs index cdd1f9452..c5406e2ec 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs @@ -181,10 +181,18 @@ public ChatCompletionOptions() [CodeGenMember("Modalities")] private IList _internalModalities = new ChangeTrackingList(); - public ChatContentModalities ContentModalities + /// + /// Specifies the content types that the model should generate in its responses. + /// + /// + /// Most models can generate text and the default ["text"] value, from , requests this. + /// Some models like gpt-4o-audio-preview can also generate audio, and this can be requested by combining ["text","audio"] via + /// the flags | . + /// + public ChatResponseModalities? ResponseModalities { get => ChatContentModalitiesExtensions.FromInternalModalities(_internalModalities); - set => _internalModalities = value.ToInternalModalities(); + set => _internalModalities = value?.ToInternalModalities(); } // CUSTOM: supplemented with custom setter to internally enable audio output via modalities. diff --git a/.dotnet/src/Custom/Chat/ChatContentModalities.cs b/.dotnet/src/Custom/Chat/ChatContentModalities.cs deleted file mode 100644 index d3ed68c92..000000000 --- a/.dotnet/src/Custom/Chat/ChatContentModalities.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace OpenAI.Chat; - -[Flags] -public enum ChatContentModalities : int -{ - Text = 1 << 0, - Audio = 1 << 1, -} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs index 73c7d2bb0..1d9607808 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContentPart.cs @@ -173,15 +173,15 @@ public static ChatMessageContentPart CreateRefusalPart(string refusal) /// Binary audio content parts may only be used with instances to represent user audio input. When referring to /// past audio output from the model, use instead. /// - /// The audio data. - /// The format of the audio data. - public static ChatMessageContentPart CreateInputAudioPart(BinaryData audioBytes, ChatInputAudioFormat audioFormat) + /// The audio data. + /// The format of the audio data. + public static ChatMessageContentPart CreateInputAudioPart(BinaryData inputAudioBytes, ChatInputAudioFormat inputAudioFormat) { - Argument.AssertNotNull(audioBytes, nameof(audioBytes)); + Argument.AssertNotNull(inputAudioBytes, nameof(inputAudioBytes)); return new ChatMessageContentPart( kind: ChatMessageContentPartKind.InputAudio, - inputAudio: new(audioBytes, audioFormat)); + inputAudio: new(inputAudioBytes, inputAudioFormat)); } /// diff --git a/.dotnet/src/Custom/Chat/ChatContentModalities.Serialization.cs b/.dotnet/src/Custom/Chat/ChatResponseModalities.Serialization.cs similarity index 65% rename from .dotnet/src/Custom/Chat/ChatContentModalities.Serialization.cs rename to .dotnet/src/Custom/Chat/ChatResponseModalities.Serialization.cs index 1e90cb9ac..aefa3a2fe 100644 --- a/.dotnet/src/Custom/Chat/ChatContentModalities.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatResponseModalities.Serialization.cs @@ -4,32 +4,32 @@ namespace OpenAI.Chat; internal static partial class ChatContentModalitiesExtensions { - internal static IList ToInternalModalities(this ChatContentModalities modalities) + internal static IList ToInternalModalities(this ChatResponseModalities modalities) { List internalModalities = []; - if (modalities.HasFlag(ChatContentModalities.Text)) + if (modalities.HasFlag(ChatResponseModalities.Text)) { internalModalities.Add(InternalCreateChatCompletionRequestModality.Text); } - if (modalities.HasFlag(ChatContentModalities.Audio)) + if (modalities.HasFlag(ChatResponseModalities.Audio)) { internalModalities.Add(InternalCreateChatCompletionRequestModality.Audio); } return internalModalities; } - internal static ChatContentModalities FromInternalModalities(IEnumerable internalModalities) + internal static ChatResponseModalities FromInternalModalities(IEnumerable internalModalities) { - ChatContentModalities result = 0; + ChatResponseModalities result = 0; foreach (InternalCreateChatCompletionRequestModality internalModality in internalModalities ?? []) { if (internalModality == InternalCreateChatCompletionRequestModality.Text) { - result |= ChatContentModalities.Text; + result |= ChatResponseModalities.Text; } else if (internalModality == InternalCreateChatCompletionRequestModality.Audio) { - result |= ChatContentModalities.Audio; + result |= ChatResponseModalities.Audio; } } return result; diff --git a/.dotnet/src/Custom/Chat/ChatResponseModalities.cs b/.dotnet/src/Custom/Chat/ChatResponseModalities.cs new file mode 100644 index 000000000..052936df3 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatResponseModalities.cs @@ -0,0 +1,26 @@ +using System; + +namespace OpenAI.Chat; + +/// +/// Specifies the types of output content the model should generate for a chat completion request. +/// +/// +/// Most models can generate text, which is the default . Some models like +/// gpt-4o-audio-preview can also generate audio, which can be requested by combining +/// +/// | . +/// +/// +[Flags] +public enum ChatResponseModalities : int +{ + /// + /// The flag that, if included, specifies that the model should generate text content in its response. + /// + Text = 1 << 0, + /// + /// The flag that, if included, specifies that the model should generate audio content in its response. + /// + Audio = 1 << 1, +} \ No newline at end of file diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index 5d4d66759..6a4120237 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -386,7 +386,7 @@ public async Task ChatWithAudio() ChatCompletionOptions options = new() { - ContentModalities = ChatContentModalities.Text | ChatContentModalities.Audio, + ResponseModalities = ChatResponseModalities.Text | ChatResponseModalities.Audio, AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Pcm16) }; From b655084ca560e6d04b7d64c9d10c9a21ff10bfad Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Tue, 21 Jan 2025 09:32:11 -0800 Subject: [PATCH 15/44] merge, plus realtime vad create_response --- .../src/Custom/AzureOpenAIClient.cs | 4 +- .../tests/ConversationTests.cs | 75 +- .dotnet/api/OpenAI.netstandard2.0.cs | 2 +- .../ConversationTurnDetectionOptions.cs | 6 +- ...imeServerVadTurnDetection.Serialization.cs | 23 +- .../InternalRealtimeServerVadTurnDetection.cs | 5 +- .openapi3/openapi3-openai.yaml | 7 + .typespec/realtime/custom.tsp | 17 +- README.md | 4 +- openapi3-original.yaml | 856 +++++------------- 10 files changed, 338 insertions(+), 661 deletions(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClient.cs index d374d0923..42b810afa 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClient.cs @@ -13,6 +13,9 @@ global using OpenAI.Models; global using OpenAI.Moderations; global using OpenAI.VectorStores; +#if !AZURE_OPENAI_GA +global using OpenAI.RealtimeConversation; +#endif using System.ClientModel; using System.ClientModel.Primitives; @@ -27,7 +30,6 @@ using Azure.Core; #if !AZURE_OPENAI_GA -global using OpenAI.RealtimeConversation; using Azure.AI.OpenAI.Assistants; using Azure.AI.OpenAI.FineTuning; using Azure.AI.OpenAI.RealtimeConversation; diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs index d9ecf1b2f..0c7ffbeb2 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs @@ -37,7 +37,7 @@ public async Task CanConfigureSession() }; await session.ConfigureSessionAsync(sessionOptions, CancellationToken); - ConversationSessionOptions responseOverrideOptions = new() + ConversationResponseOptions responseOverrideOptions = new() { ContentModalities = ConversationContentModalities.Text, }; @@ -387,6 +387,79 @@ or ConversationResponseStartedUpdate } } + [Test] + public async Task CanUseManualVadTurnDetection() + { + RealtimeConversationClient client = GetTestClient(); + using RealtimeConversationSession session = await client.StartConversationSessionAsync(CancellationToken); + + await session.ConfigureSessionAsync( + new() + { + InputTranscriptionOptions = new ConversationInputTranscriptionOptions() + { + Model = "whisper-1", + }, + TurnDetectionOptions = ConversationTurnDetectionOptions.CreateServerVoiceActivityTurnDetectionOptions( + enableAutomaticResponseCreation: false), + }, + CancellationToken); + + const string folderName = "Assets"; + const string fileName = "whats_the_weather_pcm16_24khz_mono.wav"; +#if NET6_0_OR_GREATER + using Stream audioStream = File.OpenRead(Path.Join(folderName, fileName)); +#else + using Stream audioStream = File.OpenRead($"{folderName}\\{fileName}"); +#endif + await session.SendInputAudioAsync(audioStream, CancellationToken); + + bool gotInputTranscriptionCompleted = false; + bool responseExpected = false; + bool gotResponseStarted = false; + bool gotResponseFinished = false; + + await foreach (ConversationUpdate update in session.ReceiveUpdatesAsync(CancellationToken)) + { + if (update is ConversationErrorUpdate errorUpdate) + { + Assert.Fail($"Error received: {ModelReaderWriter.Write(errorUpdate)}"); + } + + if (update is ConversationInputTranscriptionFinishedUpdate inputTranscriptionFinishedUpdate) + { + Assert.That(gotInputTranscriptionCompleted, Is.False); + Assert.That(inputTranscriptionFinishedUpdate.Transcript, Is.Not.Null.And.Not.Empty); + gotInputTranscriptionCompleted = true; + await Task.Delay(TimeSpan.FromMilliseconds(500), CancellationToken); + await session.StartResponseAsync(CancellationToken); + responseExpected = true; + } + + if (update is ConversationResponseStartedUpdate responseStartedUpdate) + { + Assert.That(responseExpected, Is.True); + Assert.That(gotInputTranscriptionCompleted, Is.True); + Assert.That(gotResponseFinished, Is.False); + gotResponseStarted = true; + } + + if (update is ConversationResponseFinishedUpdate responseFinishedUpdate) + { + Assert.That(responseExpected, Is.True); + Assert.That(gotInputTranscriptionCompleted, Is.True); + Assert.That(gotResponseStarted, Is.True); + Assert.That(gotResponseFinished, Is.False); + gotResponseFinished = true; + break; + } + } + + Assert.IsTrue(gotInputTranscriptionCompleted); + Assert.IsTrue(gotResponseStarted); + Assert.IsTrue(gotResponseFinished); + } + [Test] public async Task BadCommandProvidesError() { diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index f1621dc9f..896742826 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -2612,7 +2612,7 @@ public enum ConversationTurnDetectionKind { public abstract class ConversationTurnDetectionOptions : IJsonModel, IPersistableModel { public ConversationTurnDetectionKind Kind { get; protected internal set; } public static ConversationTurnDetectionOptions CreateDisabledTurnDetectionOptions(); - public static ConversationTurnDetectionOptions CreateServerVoiceActivityTurnDetectionOptions(float? detectionThreshold = null, TimeSpan? prefixPaddingDuration = null, TimeSpan? silenceDuration = null); + public static ConversationTurnDetectionOptions CreateServerVoiceActivityTurnDetectionOptions(float? detectionThreshold = null, TimeSpan? prefixPaddingDuration = null, TimeSpan? silenceDuration = null, bool? enableAutomaticResponseCreation = null); public static explicit operator ConversationTurnDetectionOptions(ClientResult result); public static implicit operator BinaryContent(ConversationTurnDetectionOptions conversationTurnDetectionOptions); } diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationTurnDetectionOptions.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationTurnDetectionOptions.cs index efcb54a9d..e8ebe583d 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ConversationTurnDetectionOptions.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationTurnDetectionOptions.cs @@ -18,13 +18,15 @@ public static ConversationTurnDetectionOptions CreateDisabledTurnDetectionOption public static ConversationTurnDetectionOptions CreateServerVoiceActivityTurnDetectionOptions( float? detectionThreshold = null, TimeSpan? prefixPaddingDuration = null, - TimeSpan? silenceDuration = null) + TimeSpan? silenceDuration = null, + bool? enableAutomaticResponseCreation = null) { return new InternalRealtimeServerVadTurnDetection() { Threshold = detectionThreshold, PrefixPaddingMs = prefixPaddingDuration, - SilenceDurationMs = silenceDuration + SilenceDurationMs = silenceDuration, + CreateResponse = enableAutomaticResponseCreation, }; } } \ No newline at end of file diff --git a/.dotnet/src/Generated/Models/InternalRealtimeServerVadTurnDetection.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeServerVadTurnDetection.Serialization.cs index 6bc541de0..6323d180b 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeServerVadTurnDetection.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeServerVadTurnDetection.Serialization.cs @@ -43,6 +43,11 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WritePropertyName("silence_duration_ms"u8); this.SerializeSilenceDurationMs(writer, options); } + if (Optional.IsDefined(CreateResponse) && _additionalBinaryDataProperties?.ContainsKey("create_response") != true) + { + writer.WritePropertyName("create_response"u8); + writer.WriteBooleanValue(CreateResponse.Value); + } } InternalRealtimeServerVadTurnDetection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalRealtimeServerVadTurnDetection)JsonModelCreateCore(ref reader, options); @@ -69,6 +74,7 @@ internal static InternalRealtimeServerVadTurnDetection DeserializeInternalRealti float? threshold = default; TimeSpan? prefixPaddingMs = default; TimeSpan? silenceDurationMs = default; + bool? createResponse = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) @@ -95,12 +101,27 @@ internal static InternalRealtimeServerVadTurnDetection DeserializeInternalRealti DeserializeMillisecondDuration(prop, ref silenceDurationMs); continue; } + if (prop.NameEquals("create_response"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createResponse = prop.Value.GetBoolean(); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRealtimeServerVadTurnDetection(kind, additionalBinaryDataProperties, threshold, prefixPaddingMs, silenceDurationMs); + return new InternalRealtimeServerVadTurnDetection( + kind, + additionalBinaryDataProperties, + threshold, + prefixPaddingMs, + silenceDurationMs, + createResponse); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalRealtimeServerVadTurnDetection.cs b/.dotnet/src/Generated/Models/InternalRealtimeServerVadTurnDetection.cs index 2d781bf81..6e89b9f0d 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeServerVadTurnDetection.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeServerVadTurnDetection.cs @@ -13,11 +13,12 @@ public InternalRealtimeServerVadTurnDetection() : base(RealtimeConversation.Conv { } - internal InternalRealtimeServerVadTurnDetection(RealtimeConversation.ConversationTurnDetectionKind kind, IDictionary additionalBinaryDataProperties, float? threshold, TimeSpan? prefixPaddingMs, TimeSpan? silenceDurationMs) : base(kind, additionalBinaryDataProperties) + internal InternalRealtimeServerVadTurnDetection(RealtimeConversation.ConversationTurnDetectionKind kind, IDictionary additionalBinaryDataProperties, float? threshold, TimeSpan? prefixPaddingMs, TimeSpan? silenceDurationMs, bool? createResponse) : base(kind, additionalBinaryDataProperties) { Threshold = threshold; PrefixPaddingMs = prefixPaddingMs; SilenceDurationMs = silenceDurationMs; + CreateResponse = createResponse; } public float? Threshold { get; set; } @@ -25,5 +26,7 @@ internal InternalRealtimeServerVadTurnDetection(RealtimeConversation.Conversatio public TimeSpan? PrefixPaddingMs { get; set; } public TimeSpan? SilenceDurationMs { get; set; } + + public bool? CreateResponse { get; set; } } } diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index b16320a94..c9d98296b 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -11636,13 +11636,20 @@ components: threshold: type: number format: float + description: Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher threshold will require louder audio to activate the model, and thus might perform better in noisy environments. default: 0.5 prefix_padding_ms: type: string format: duration + description: Amount of audio to include before the VAD detected speech (in milliseconds). Defaults to 300ms. silence_duration_ms: type: string format: duration + description: Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms. With shorter values the model will respond more quickly, but may jump in on short pauses from the user. + create_response: + type: boolean + description: Whether or not to automatically generate a response when VAD is enabled. true by default. + default: true allOf: - $ref: '#/components/schemas/RealtimeTurnDetection' RealtimeSessionBase: diff --git a/.typespec/realtime/custom.tsp b/.typespec/realtime/custom.tsp index 73d47fe9b..8a555b577 100644 --- a/.typespec/realtime/custom.tsp +++ b/.typespec/realtime/custom.tsp @@ -99,13 +99,28 @@ model RealtimeTurnDetection { model RealtimeServerVadTurnDetection extends RealtimeTurnDetection { type: RealtimeTurnDetectionType.server_vad; + + /** + * Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher threshold will require louder audio to activate the model, and thus might perform better in noisy environments. + */ threshold?: float32 = 0.5; // @encode("milliseconds", int32) + /** + * Amount of audio to include before the VAD detected speech (in milliseconds). Defaults to 300ms. + */ prefix_padding_ms?: duration; // = 300ms // @encode("milliseconds", int32) - silence_duration_ms?: duration; // = 200,s + /** + * Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms. With shorter values the model will respond more quickly, but may jump in on short pauses from the user. + */ + silence_duration_ms?: duration; // = 500ms + + /** + * Whether or not to automatically generate a response when VAD is enabled. true by default. + */ + create_response?: boolean = true; } model RealtimeServerEventRateLimitsUpdatedRateLimitsItem { diff --git a/README.md b/README.md index c105bcdca..88b4057de 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ https://dev.azure.com/project-argos/Sorento/_wiki/wikis/Sorento.wiki/3021/Genera Snapshot: https://project-argos@dev.azure.com/project-argos/Sorento/_git/export-api ``` -commit 2b12183ef3a0ddd81b3b4f51c201479183b34788 (HEAD -> main, origin/main) +commit 41af04dc4767cfd11ca4fbc7edf2e5a67a564440 (HEAD -> main, origin/main) Author: Git-Mirror-Tool Synchronizer -Date: Mon Jan 6 22:44:48 2025 +0000 +Date: Mon Jan 13 22:49:02 2025 +0000 ``` Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk diff --git a/openapi3-original.yaml b/openapi3-original.yaml index 46e8a9e3a..bd8c4b221 100644 --- a/openapi3-original.yaml +++ b/openapi3-original.yaml @@ -1627,23 +1627,14 @@ paths: main(); - response: > - {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", - "system_fingerprint": "fp_44709d6fcb", - "choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]} - - - {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", - "system_fingerprint": "fp_44709d6fcb", - "choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} + response: | + {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]} + {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} .... - - {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", - "system_fingerprint": "fp_44709d6fcb", - "choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} - title: Functions request: curl: > @@ -3037,10 +3028,8 @@ paths: the given ID. examples: request: - curl: > - curl - https://api.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F - \ + curl: | + curl https://api.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ -H "Authorization: Bearer $OPENAI_API_KEY" python: | from openai import OpenAI @@ -3208,10 +3197,8 @@ paths: fine-tuning job. examples: request: - curl: > - curl - https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/checkpoints - \ + curl: | + curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/checkpoints \ -H "Authorization: Bearer $OPENAI_API_KEY" response: > { @@ -3700,10 +3687,8 @@ paths: returns: Deletion status. examples: request: - curl: > - curl - https://api.openai.com/v1/models/ft:gpt-4o-mini:acemeco:suffix:abc123 - \ + curl: | + curl https://api.openai.com/v1/models/ft:gpt-4o-mini:acemeco:suffix:abc123 \ -X DELETE \ -H "Authorization: Bearer $OPENAI_API_KEY" python: | @@ -4027,10 +4012,8 @@ paths: returns: A list of admin API key objects. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/admin_api_keys?after=key_abc&limit=20 - \ + curl: | + curl https://api.openai.com/v1/organization/admin_api_keys?after=key_abc&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: | @@ -4476,13 +4459,9 @@ paths: [Costs](/docs/api-reference/usage/costs_object) objects. examples: request: - curl: > - curl - "https://api.openai.com/v1/organization/costs?start_time=1730419200&limit=1" - \ - + curl: | + curl "https://api.openai.com/v1/organization/costs?start_time=1730419200&limit=1" \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" response: | { @@ -4547,10 +4526,8 @@ paths: returns: A list of [Invite](/docs/api-reference/invite/object) objects. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/invites?after=invite-abc&limit=20 - \ + curl: | + curl https://api.openai.com/v1/organization/invites?after=invite-abc&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: | @@ -4764,10 +4741,8 @@ paths: returns: A list of [Project](/docs/api-reference/projects/object) objects. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/projects?after=proj_abc&limit=20&include_archived=false - \ + curl: | + curl https://api.openai.com/v1/organization/projects?after=proj_abc&limit=20&include_archived=false \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -4965,10 +4940,8 @@ paths: objects. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/projects/proj_abc/api_keys?after=key_abc&limit=20 - \ + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys?after=key_abc&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -5038,10 +5011,8 @@ paths: matching the specified ID. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc - \ + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -5102,10 +5073,8 @@ paths: service account examples: request: - curl: > - curl -X DELETE - https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc - \ + curl: | + curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -5220,10 +5189,8 @@ paths: objects. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/projects/proj_abc/rate_limits?after=rl_xxx&limit=20 - \ + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/rate_limits?after=rl_xxx&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: | @@ -5295,10 +5262,8 @@ paths: object. examples: request: - curl: > - curl -X POST - https://api.openai.com/v1/organization/projects/proj_abc/rate_limits/rl_xxx - \ + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/rate_limits/rl_xxx \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -5371,10 +5336,8 @@ paths: objects. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/projects/proj_abc/service_accounts?after=custom_id&limit=20 - \ + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts?after=custom_id&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -5435,10 +5398,8 @@ paths: object. examples: request: - curl: > - curl -X POST - https://api.openai.com/v1/organization/projects/proj_abc/service_accounts - \ + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/service_accounts \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -5494,10 +5455,8 @@ paths: object matching the specified ID. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc - \ + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -5541,10 +5500,8 @@ paths: an archived project, which has no service accounts examples: request: - curl: > - curl -X DELETE - https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc - \ + curl: | + curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -5606,10 +5563,8 @@ paths: objects. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/projects/proj_abc/users?after=user_abc&limit=20 - \ + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/users?after=user_abc&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -5733,10 +5688,8 @@ paths: matching the specified ID. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc - \ + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -5794,10 +5747,8 @@ paths: object. examples: request: - curl: > - curl -X POST - https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc - \ + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -5851,10 +5802,8 @@ paths: archived project, which has no users examples: request: - curl: > - curl -X DELETE - https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc - \ + curl: | + curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -5972,13 +5921,9 @@ paths: usage](/docs/api-reference/usage/audio_speeches_object) objects. examples: request: - curl: > - curl - "https://api.openai.com/v1/organization/usage/audio_speeches?start_time=1730419200&limit=1" - \ - + curl: | + curl "https://api.openai.com/v1/organization/usage/audio_speeches?start_time=1730419200&limit=1" \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" response: > { @@ -6112,13 +6057,9 @@ paths: usage](/docs/api-reference/usage/audio_transcriptions_object) objects. examples: request: - curl: > - curl - "https://api.openai.com/v1/organization/usage/audio_transcriptions?start_time=1730419200&limit=1" - \ - + curl: | + curl "https://api.openai.com/v1/organization/usage/audio_transcriptions?start_time=1730419200&limit=1" \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" response: > { @@ -6225,13 +6166,9 @@ paths: objects. examples: request: - curl: > - curl - "https://api.openai.com/v1/organization/usage/code_interpreter_sessions?start_time=1730419200&limit=1" - \ - + curl: | + curl "https://api.openai.com/v1/organization/usage/code_interpreter_sessions?start_time=1730419200&limit=1" \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" response: > { @@ -6370,13 +6307,9 @@ paths: usage](/docs/api-reference/usage/completions_object) objects. examples: request: - curl: > - curl - "https://api.openai.com/v1/organization/usage/completions?start_time=1730419200&limit=1" - \ - + curl: | + curl "https://api.openai.com/v1/organization/usage/completions?start_time=1730419200&limit=1" \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" response: > { @@ -6515,13 +6448,9 @@ paths: usage](/docs/api-reference/usage/embeddings_object) objects. examples: request: - curl: > - curl - "https://api.openai.com/v1/organization/usage/embeddings?start_time=1730419200&limit=1" - \ - + curl: | + curl "https://api.openai.com/v1/organization/usage/embeddings?start_time=1730419200&limit=1" \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" response: > { @@ -6687,13 +6616,9 @@ paths: usage](/docs/api-reference/usage/images_object) objects. examples: request: - curl: > - curl - "https://api.openai.com/v1/organization/usage/images?start_time=1730419200&limit=1" - \ - + curl: | + curl "https://api.openai.com/v1/organization/usage/images?start_time=1730419200&limit=1" \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" response: | { @@ -6829,13 +6754,9 @@ paths: usage](/docs/api-reference/usage/moderations_object) objects. examples: request: - curl: > - curl - "https://api.openai.com/v1/organization/usage/moderations?start_time=1730419200&limit=1" - \ - + curl: | + curl "https://api.openai.com/v1/organization/usage/moderations?start_time=1730419200&limit=1" \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" response: > { @@ -6941,13 +6862,9 @@ paths: usage](/docs/api-reference/usage/vector_stores_object) objects. examples: request: - curl: > - curl - "https://api.openai.com/v1/organization/usage/vector_stores?start_time=1730419200&limit=1" - \ - + curl: | + curl "https://api.openai.com/v1/organization/usage/vector_stores?start_time=1730419200&limit=1" \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" response: > { @@ -7008,10 +6925,8 @@ paths: returns: A list of [User](/docs/api-reference/users/object) objects. examples: request: - curl: > - curl - https://api.openai.com/v1/organization/users?after=user_abc&limit=20 - \ + curl: | + curl https://api.openai.com/v1/organization/users?after=user_abc&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" response: @@ -7526,99 +7441,52 @@ paths: } main(); - response: > + response: | event: thread.created - - data: - {"id":"thread_123","object":"thread","created_at":1710348075,"metadata":{}} - + data: {"id":"thread_123","object":"thread","created_at":1710348075,"metadata":{}} event: thread.run.created - - data: - {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} - + data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} event: thread.run.queued - - data: - {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} - + data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} event: thread.run.in_progress - - data: - {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} - + data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} event: thread.run.step.created - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.run.step.in_progress - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.message.created - - data: - {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], - "metadata":{}} - + data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}} event: thread.message.in_progress - - data: - {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], - "metadata":{}} - + data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}} event: thread.message.delta - - data: - {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} - + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} ... - event: thread.message.delta - - data: - {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" - today"}}]}} - + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} event: thread.message.delta - - data: - {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} - + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} event: thread.message.completed - - data: - {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! - How can I assist you today?","annotations":[]}}], "metadata":{}} - + data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}], "metadata":{}} event: thread.run.step.completed - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} event: thread.run.completed - {"id":"run_123","object":"thread.run","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1713226836,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1713226837,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} - event: done - data: [DONE] - title: Streaming with Functions request: @@ -7749,102 +7617,46 @@ paths: main(); - response: > + response: | event: thread.created - - data: - {"id":"thread_123","object":"thread","created_at":1710351818,"metadata":{}} - + data: {"id":"thread_123","object":"thread","created_at":1710351818,"metadata":{}} event: thread.run.created - - data: - {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get - the current weather in a given - location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The - city and state, e.g. San Francisco, - CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.queued - - data: - {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get - the current weather in a given - location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The - city and state, e.g. San Francisco, - CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.in_progress - - data: - {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get - the current weather in a given - location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The - city and state, e.g. San Francisco, - CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.step.created - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} event: thread.run.step.in_progress - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} event: thread.run.step.delta - - data: - {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"","output":null}}]}}} - + data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"","output":null}}]}}} event: thread.run.step.delta - - data: - {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"{\""}}]}}} - + data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"{\""}}]}}} event: thread.run.step.delta - - data: - {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"location"}}]}}} - + data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"location"}}]}}} ... - event: thread.run.step.delta - - data: - {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"ahrenheit"}}]}}} - + data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"ahrenheit"}}]}}} event: thread.run.step.delta - - data: - {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"\"}"}}]}}} - + data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"\"}"}}]}}} event: thread.run.requires_action - - data: - {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"requires_action","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":{"type":"submit_tool_outputs","submit_tool_outputs":{"tool_calls":[{"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San - Francisco, - CA\",\"unit\":\"fahrenheit\"}"}}]}},"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get - the current weather in a given - location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The - city and state, e.g. San Francisco, - CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"requires_action","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":{"type":"submit_tool_outputs","submit_tool_outputs":{"tool_calls":[{"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}"}}]}},"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: done - data: [DONE] /threads/{thread_id}: get: @@ -8327,10 +8139,8 @@ paths: specified ID. examples: request: - curl: > - curl - https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 - \ + curl: | + curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "OpenAI-Beta: assistants=v2" @@ -8417,10 +8227,8 @@ paths: returns: The modified [message](/docs/api-reference/messages/object) object. examples: request: - curl: > - curl - https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 - \ + curl: | + curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "OpenAI-Beta: assistants=v2" \ @@ -8515,10 +8323,8 @@ paths: returns: Deletion status examples: request: - curl: > - curl -X DELETE - https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 - \ + curl: | + curl -X DELETE https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "OpenAI-Beta: assistants=v2" @@ -8761,16 +8567,10 @@ paths: description: The ID of the thread to run. - name: include[] in: query - description: > - A list of additional fields to include in the response. Currently - the only supported value is - `step_details.tool_calls[*].file_search.results[*].content` to fetch - the file search result content. - + description: | + A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - See the [file search tool - documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) - for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. schema: type: array items: @@ -8907,92 +8707,49 @@ paths: } main(); - response: > + response: | event: thread.run.created - - data: - {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.queued - - data: - {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.in_progress - - data: - {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710330641,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710330641,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.step.created - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.run.step.in_progress - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.message.created - - data: - {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - + data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.in_progress - - data: - {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - + data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.delta - - data: - {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} - + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} ... - event: thread.message.delta - - data: - {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" - today"}}]}} - + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} event: thread.message.delta - - data: - {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} - + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} event: thread.message.completed - - data: - {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710330642,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! - How can I assist you today?","annotations":[]}}],"metadata":{}} - + data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710330642,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}],"metadata":{}} event: thread.run.step.completed - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710330642,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710330642,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} event: thread.run.completed - - data: - {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710330641,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710330642,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710330641,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710330642,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: done - data: [DONE] - title: Streaming with Functions request: @@ -9112,92 +8869,49 @@ paths: main(); - response: > + response: | event: thread.run.created - - data: - {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.queued - - data: - {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.in_progress - - data: - {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710348075,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710348075,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.step.created - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.run.step.in_progress - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.message.created - - data: - {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - + data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.in_progress - - data: - {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - + data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.delta - - data: - {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} - + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} ... - event: thread.message.delta - - data: - {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" - today"}}]}} - + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} event: thread.message.delta - - data: - {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} - + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} event: thread.message.completed - - data: - {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! - How can I assist you today?","annotations":[]}}],"metadata":{}} - + data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}],"metadata":{}} event: thread.run.step.completed - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} event: thread.run.completed - - data: - {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710348075,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710348077,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710348075,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710348077,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: done - data: [DONE] /threads/{thread_id}/runs/{run_id}: get: @@ -9468,10 +9182,8 @@ paths: specified ID. examples: request: - curl: > - curl - https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/cancel - \ + curl: | + curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/cancel \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "OpenAI-Beta: assistants=v2" \ -X POST @@ -9594,16 +9306,10 @@ paths: type: string - name: include[] in: query - description: > - A list of additional fields to include in the response. Currently - the only supported value is - `step_details.tool_calls[*].file_search.results[*].content` to fetch - the file search result content. - + description: | + A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - See the [file search tool - documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) - for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. schema: type: array items: @@ -9625,10 +9331,8 @@ paths: objects. examples: request: - curl: > - curl - https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps - \ + curl: | + curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" @@ -9717,16 +9421,10 @@ paths: description: The ID of the run step to retrieve. - name: include[] in: query - description: > - A list of additional fields to include in the response. Currently - the only supported value is - `step_details.tool_calls[*].file_search.results[*].content` to fetch - the file search result content. - + description: | + A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - See the [file search tool - documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) - for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. schema: type: array items: @@ -9748,10 +9446,8 @@ paths: matching the specified ID. examples: request: - curl: > - curl - https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 - \ + curl: | + curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" @@ -9853,10 +9549,8 @@ paths: examples: - title: Default request: - curl: > - curl - https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs - \ + curl: | + curl https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ @@ -9962,10 +9656,8 @@ paths: } - title: Streaming request: - curl: > - curl - https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs - \ + curl: | + curl https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ @@ -10024,121 +9716,55 @@ paths: main(); - response: > + response: | event: thread.run.step.completed - - data: - {"id":"step_001","object":"thread.run.step","created_at":1710352449,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"completed","cancelled_at":null,"completed_at":1710352475,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[{"id":"call_iWr0kQ2EaYMaxNdl0v3KYkx7","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San - Francisco, CA\",\"unit\":\"fahrenheit\"}","output":"70 degrees and - sunny."}}]},"usage":{"prompt_tokens":291,"completion_tokens":24,"total_tokens":315}} - + data: {"id":"step_001","object":"thread.run.step","created_at":1710352449,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"completed","cancelled_at":null,"completed_at":1710352475,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[{"id":"call_iWr0kQ2EaYMaxNdl0v3KYkx7","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}","output":"70 degrees and sunny."}}]},"usage":{"prompt_tokens":291,"completion_tokens":24,"total_tokens":315}} event: thread.run.queued - - data: - {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":1710352448,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get - the current weather in a given - location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The - city and state, e.g. San Francisco, - CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":1710352448,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.in_progress - - data: - {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710352475,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get - the current weather in a given - location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The - city and state, e.g. San Francisco, - CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710352475,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.step.created - - data: - {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} - + data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} event: thread.run.step.in_progress - - data: - {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} - + data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} event: thread.message.created - - data: - {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - + data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.in_progress - - data: - {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - + data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.delta - - data: - {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"The","annotations":[]}}]}} - + data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"The","annotations":[]}}]}} event: thread.message.delta - - data: - {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" - current"}}]}} - + data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" current"}}]}} event: thread.message.delta - - data: - {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" - weather"}}]}} - + data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" weather"}}]}} ... - event: thread.message.delta - - data: - {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" - sunny"}}]}} - + data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" sunny"}}]}} event: thread.message.delta - - data: - {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"."}}]}} - + data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"."}}]}} event: thread.message.completed - - data: - {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710352477,"role":"assistant","content":[{"type":"text","text":{"value":"The - current weather in San Francisco, CA is 70 degrees Fahrenheit and - sunny.","annotations":[]}}],"metadata":{}} - + data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710352477,"role":"assistant","content":[{"type":"text","text":{"value":"The current weather in San Francisco, CA is 70 degrees Fahrenheit and sunny.","annotations":[]}}],"metadata":{}} event: thread.run.step.completed - - data: - {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710352477,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":{"prompt_tokens":329,"completion_tokens":18,"total_tokens":347}} - + data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710352477,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":{"prompt_tokens":329,"completion_tokens":18,"total_tokens":347}} event: thread.run.completed - - data: - {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710352475,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710352477,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get - the current weather in a given - location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The - city and state, e.g. San Francisco, - CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - + data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710352475,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710352477,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: done - data: [DONE] /uploads: post: @@ -11011,10 +10637,8 @@ paths: file](/docs/api-reference/vector-stores-files/file-object) object. examples: request: - curl: > - curl - https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 - \ + curl: | + curl https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" @@ -11086,10 +10710,8 @@ paths: returns: Deletion status examples: request: - curl: > - curl - https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 - \ + curl: | + curl https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ @@ -11258,10 +10880,8 @@ paths: object. examples: request: - curl: > - curl - https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 - \ + curl: | + curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" @@ -11343,10 +10963,8 @@ paths: returns: The modified vector store file batch object. examples: request: - curl: > - curl - https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel - \ + curl: | + curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ @@ -11479,10 +11097,8 @@ paths: file](/docs/api-reference/vector-stores-files/file-object) objects. examples: request: - curl: > - curl - https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files - \ + curl: | + curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" @@ -11940,17 +11556,10 @@ components: type: integer minimum: 1 maximum: 50 - description: > - The maximum number of results the file search tool should - output. The default is 20 for `gpt-4*` models and 5 for - `gpt-3.5-turbo`. This number should be between 1 and 50 - inclusive. - + description: | + The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than - `max_num_results` results. See the [file search tool - documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) - for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: "#/components/schemas/FileSearchRankingOptions" required: @@ -14251,13 +13860,8 @@ components: items: type: string stream: - description: > - If set, partial message deltas will be sent, like in ChatGPT. Tokens - will be sent as data-only [server-sent - events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) - as they become available, with the stream terminated by a `data: - [DONE]` message. [Example Python - code](https://cookbook.openai.com/examples/how_to_stream_completions). + description: | + If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). type: boolean nullable: true default: false @@ -14648,23 +14252,14 @@ components: x-oaiMeta: name: The chat completion chunk object group: chat - example: > - {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", - "system_fingerprint": "fp_44709d6fcb", - "choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]} - - - {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", - "system_fingerprint": "fp_44709d6fcb", - "choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} + example: | + {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]} + {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]} .... - - {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", - "system_fingerprint": "fp_44709d6fcb", - "choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} CreateCompletionRequest: type: object properties: @@ -14800,15 +14395,10 @@ components: default: 16 example: 16 nullable: true - description: > - The maximum number of [tokens](/tokenizer) that can be generated in - the completion. - + description: | + The maximum number of [tokens](/tokenizer) that can be generated in the completion. - The token count of your prompt plus `max_tokens` cannot exceed the - model's context length. [Example Python - code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) - for counting tokens. + The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. n: type: integer minimum: 1 @@ -14869,13 +14459,8 @@ components: type: string example: '["\n"]' stream: - description: > - Whether to stream back partial progress. If set, tokens will be sent - as data-only [server-sent - events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) - as they become available, with the stream terminated by a `data: - [DONE]` message. [Example Python - code](https://cookbook.openai.com/examples/how_to_stream_completions). + description: | + Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). type: boolean nullable: true default: false @@ -15050,16 +14635,8 @@ components: additionalProperties: false properties: input: - description: > - Input text to embed, encoded as a string or array of tokens. To - embed multiple inputs in a single request, pass an array of strings - or array of token arrays. The input must not exceed the max input - tokens for the model (8192 tokens for `text-embedding-ada-002`), - cannot be an empty string, and any array must be 2048 dimensions or - less. [Example Python - code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) - for counting tokens. Some models may also impose a limit on total - number of tokens summed across inputs. + description: | + Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. Some models may also impose a limit on total number of tokens summed across inputs. example: The quick brown fox jumped over the lazy dog oneOf: - type: string @@ -17211,14 +16788,10 @@ components: FileSearchRankingOptions: title: File search tool call ranking options type: object - description: > - The ranking options for the file search. If not specified, the file - search tool will use the `auto` ranker and a score_threshold of 0. - + description: | + The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool - documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) - for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. properties: ranker: type: string @@ -21647,7 +21220,7 @@ components: } ] } - RealtimeServerEventOutputAudioDelta: + RealtimeServerEventResponseAudioDelta: type: object description: Returned when the model-generated audio is updated. properties: @@ -21695,7 +21268,7 @@ components: "content_index": 0, "delta": "Base64EncodedAudioDelta" } - RealtimeServerEventOutputAudioDone: + RealtimeServerEventResponseAudioDone: type: object description: > Returned when the model-generated audio is done. Also emitted when a @@ -21742,7 +21315,7 @@ components: "output_index": 0, "content_index": 0 } - RealtimeServerEventOutputAudioTranscriptDelta: + RealtimeServerEventResponseAudioTranscriptDelta: type: object description: > Returned when the model-generated transcription of audio output is @@ -21792,7 +21365,7 @@ components: "content_index": 0, "delta": "Hello, how can I a" } - RealtimeServerEventOutputAudioTranscriptDone: + RealtimeServerEventResponseAudioTranscriptDone: type: object description: | Returned when the model-generated transcription of audio output is done @@ -26141,24 +25714,12 @@ x-oaiMeta: - id: assistants-streaming title: Streaming beta: true - description: > - Stream the result of executing a Run or resuming a Run after submitting - tool outputs. - - You can stream events from the [Create Thread and - Run](/docs/api-reference/runs/createThreadAndRun), - - [Create Run](/docs/api-reference/runs/createRun), and [Submit Tool - Outputs](/docs/api-reference/runs/submitToolOutputs) - - endpoints by passing `"stream": true`. The response will be a - [Server-Sent - events](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events) - stream. - - Our Node and Python SDKs provide helpful utilities to make streaming - easy. Reference the - + description: | + Stream the result of executing a Run or resuming a Run after submitting tool outputs. + You can stream events from the [Create Thread and Run](/docs/api-reference/runs/createThreadAndRun), + [Create Run](/docs/api-reference/runs/createRun), and [Submit Tool Outputs](/docs/api-reference/runs/submitToolOutputs) + endpoints by passing `"stream": true`. The response will be a [Server-Sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events) stream. + Our Node and Python SDKs provide helpful utilities to make streaming easy. Reference the [Assistants API quickstart](/docs/assistants/overview) to learn more. navigationGroup: assistants sections: @@ -26173,18 +25734,11 @@ x-oaiMeta: path: events - id: administration title: Administration - description: > + description: | Programmatically manage your organization. - - The Audit Logs endpoint provides a log of all actions taken in the - organization for security and monitoring purposes. - - To access these endpoints please generate an Admin API Key through the - [API Platform Organization overview](/organization/admin-keys). Admin - API keys cannot be used for non-administration endpoints. - - For best practices on setting up your organization, please refer to this - [guide](/docs/guides/production-best-practices#setting-up-your-organization) + The Audit Logs endpoint provides a log of all actions taken in the organization for security and monitoring purposes. + To access these endpoints please generate an Admin API Key through the [API Platform Organization overview](/organization/admin-keys). Admin API keys cannot be used for non-administration endpoints. + For best practices on setting up your organization, please refer to this [guide](/docs/guides/production-best-practices#setting-up-your-organization) navigationGroup: administration - id: admin-api-keys title: Admin API Keys @@ -26592,16 +26146,16 @@ x-oaiMeta: key: RealtimeServerEventResponseTextDone path: - type: object - key: RealtimeServerEventOutputAudioTranscriptDelta + key: RealtimeServerEventResponseAudioTranscriptDelta path: - type: object - key: RealtimeServerEventOutputAudioTranscriptDone + key: RealtimeServerEventResponseAudioTranscriptDone path: - type: object - key: RealtimeServerEventOutputAudioDelta + key: RealtimeServerEventResponseAudioDelta path: - type: object - key: RealtimeServerEventOutputAudioDone + key: RealtimeServerEventResponseAudioDone path: - type: object key: RealtimeServerEventResponseFunctionCallArgumentsDelta From 444e6cd4c9ee55054c22649386d04af7c1675b88 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Tue, 21 Jan 2025 17:21:41 -0800 Subject: [PATCH 16/44] update to 2025-01-01-preview target --- .../sdk/openai/Azure.AI.OpenAI/assets.json | 2 +- .../src/Custom/AzureOpenAIClientOptions.cs | 4 +- .../Azure.AI.OpenAI/tests/BatchTests.cs | 51 +- .../openai/Azure.AI.OpenAI/tests/ChatTests.cs | 19 +- .../tests/ConversationTestFixtureBase.cs | 19 +- .../tests/ConversationTests.cs | 48 +- .../openai/Azure.AI.OpenAI/tests/FileTests.cs | 39 +- .../Azure.AI.OpenAI/tests/FineTuningTests.cs | 86 +- ...pi3-azure-openai-2024-06-01-generated.yaml | 1 + ...e-openai-2024-08-01-preview-generated.yaml | 1 + ...e-openai-2024-09-01-preview-generated.yaml | 1 + ...e-openai-2024-10-01-preview-generated.yaml | 1 + ...pi3-azure-openai-2024-10-21-generated.yaml | 1 + ...e-openai-2024-12-01-preview-generated.yaml | 1 + ...e-openai-2025-01-01-preview-generated.yaml | 3438 +++++++++++++++++ .typespec.azure/chat/models.request.tsp | 4 +- .typespec.azure/common/models.rai.tsp | 6 +- .typespec.azure/main.tsp | 7 +- 18 files changed, 3671 insertions(+), 58 deletions(-) create mode 100644 .openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json index 56b1f7e14..7f4ce84fe 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "dotnet.azure/openai/Azure.AI.OpenAI", - "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_d24fa6bfaa" + "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_42ce3a00d0" } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs index d96f8ffe3..b2eedd95f 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs @@ -59,6 +59,7 @@ public AzureOpenAIClientOptions(ServiceVersion version = LatestVersion) ServiceVersion.V2024_09_01_Preview => "2024-09-01-preview", ServiceVersion.V2024_10_01_Preview => "2024-10-01-preview", ServiceVersion.V2024_12_01_Preview => "2024-12-01-preview", + ServiceVersion.V2025_01_01_Preview => "2025-01-01-preview", #endif ServiceVersion.V2024_06_01 => "2024-06-01", ServiceVersion.V2024_10_21 => "2024-10-21", @@ -79,6 +80,7 @@ public enum ServiceVersion V2024_10_21 = 4, #if !AZURE_OPENAI_GA V2024_12_01_Preview = 5, + V2025_01_01_Preview = 6, #endif } @@ -111,7 +113,7 @@ protected override TimeSpan GetNextDelay(PipelineMessage message, int tryCount) } #if !AZURE_OPENAI_GA - private const ServiceVersion LatestVersion = ServiceVersion.V2024_12_01_Preview; + private const ServiceVersion LatestVersion = ServiceVersion.V2025_01_01_Preview; #else private const ServiceVersion LatestVersion = ServiceVersion.V2024_10_21; #endif diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs index 15fb083c9..8dc29c644 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs @@ -31,10 +31,6 @@ public class BatchTests : AoaiTestBase { public BatchTests(bool isAsync) : base(isAsync) { - if (new AzureOpenAIClientOptions().Version == "2024-12-01-preview") - { - Assert.Inconclusive("2024-12-01-preview not currently supported for files, fine-tuning, and related routes"); - } } [Test] @@ -42,9 +38,17 @@ public BatchTests(bool isAsync) : base(isAsync) public void CanCreateClient() => Assert.That(GetTestClient(), Is.InstanceOf()); [RecordedTest] - public async Task CanUploadFileForBatch() +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task CanUploadFileForBatch(AzureOpenAIClientOptions.ServiceVersion? version) { - BatchClient batchClient = GetTestClient(); + BatchClient batchClient = GetTestClient(GetTestClientOptions(version)); OpenAIFileClient fileClient = GetTestClientFrom(batchClient); OpenAIFile newFile = await fileClient.UploadFileAsync( @@ -70,10 +74,18 @@ public async Task CanUploadFileForBatch() } [RecordedTest] +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] [Category("LongRunning")] // observed live runtime up to 5 minutes - public async Task CanCancelBatch() + public async Task CanCancelBatch(AzureOpenAIClientOptions.ServiceVersion? version) { - BatchClient batchClient = GetTestClient(); + BatchClient batchClient = GetTestClient(GetTestClientOptions(version)); OpenAIFileClient fileClient = GetTestClientFrom(batchClient); string deploymentName = TestConfig.GetConfig()!.Deployment!; @@ -118,10 +130,18 @@ public async Task CanCancelBatch() } [RecordedTest] +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] [Category("LongRunning")] // observed live runtime typically varies from 6 - 15 minutes - public async Task SimpleBatchCompletionsTest() + public async Task SimpleBatchCompletionsTest(AzureOpenAIClientOptions.ServiceVersion? version) { - BatchClient batchClient = GetTestClient(); + BatchClient batchClient = GetTestClient(GetTestClientOptions(version)); OpenAIFileClient fileClient = GetTestClientFrom(batchClient); string deploymentName = TestConfig.GetConfig()!.Deployment!; @@ -213,6 +233,17 @@ public async Task SimpleBatchCompletionsTest() } } + private TestClientOptions GetTestClientOptions(AzureOpenAIClientOptions.ServiceVersion? version) + { +#if !AZURE_OPENAI_GA + if (version != AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview) + { + Assert.Inconclusive("/batches not yet fully supported after 2024-10-01-preview"); + } +#endif + return version is null ? new TestClientOptions() : new TestClientOptions(version.Value); + } + private List GetVerifiedBatchOutputsOf( BinaryData downloadBytes, IList expectedCustomIds) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs index 5447a6367..7936f7a08 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs @@ -673,12 +673,22 @@ public async Task SearchExtensionWorksStreaming() } [RecordedTest] - public async Task AsyncContentFilterWorksStreaming() +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task AsyncContentFilterWorksStreaming(AzureOpenAIClientOptions.ServiceVersion? version) { // Precondition: the target deployment is configured with an async content filter that includes a // custom blocklist that will filter variations of the word 'banana.' - ChatClient client = GetTestClient(TestConfig.GetConfig("chat_with_async_filter")); + ChatClient client = GetTestClient( + TestConfig.GetConfig("chat_with_async_filter"), + GetTestClientOptions(version)); StringBuilder contentBuilder = new(); @@ -739,6 +749,11 @@ public async Task ChatWithO1Works() #endregion #region Helper methods + private TestClientOptions GetTestClientOptions(AzureOpenAIClientOptions.ServiceVersion? version) + { + return version is null ? new TestClientOptions() : new TestClientOptions(version.Value); + } + private void ValidateUpdate(StreamingChatCompletionUpdate update, StringBuilder builder, ref bool foundPromptFilter, ref bool foundResponseFilter, ref ChatTokenUsage? usage) { if (update.CreatedAt == UNIX_EPOCH) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs index 971a38978..faa4b2e99 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs @@ -40,17 +40,28 @@ public ConversationTestFixtureBase(bool isAsync) } } - public RealtimeConversationClient GetTestClient() => GetTestClient(DefaultConfiguration); - public RealtimeConversationClient GetTestClient(string configurationName) => GetTestClient(TestConfig.GetConfig(configurationName)); - public RealtimeConversationClient GetTestClient(IConfiguration testConfig) + public TestClientOptions GetTestClientOptions(AzureOpenAIClientOptions.ServiceVersion? version) { + if (version != AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview) + { + Assert.Inconclusive("/realtime not yet supported outside of 2024-10-01-preview"); + } + return version is null ? new TestClientOptions() : new TestClientOptions(version.Value); + } + + public RealtimeConversationClient GetTestClient(TestClientOptions clientOptions = null) => GetTestClient(DefaultConfiguration, clientOptions); + public RealtimeConversationClient GetTestClient(string configurationName, TestClientOptions clientOptions = null) => GetTestClient(TestConfig.GetConfig(configurationName), clientOptions); + public RealtimeConversationClient GetTestClient(IConfiguration testConfig, TestClientOptions clientOptions = null) + { + clientOptions ??= new(); + Uri endpoint = testConfig.Endpoint; ApiKeyCredential key = new(testConfig.Key); string deployment = testConfig.Deployment; Console.WriteLine($"--- Connecting to endpoint: {endpoint.AbsoluteUri}"); - AzureOpenAIClient topLevelClient = new(endpoint, key); + AzureOpenAIClient topLevelClient = new(endpoint, key, clientOptions); RealtimeConversationClient client = topLevelClient.GetRealtimeConversationClient(testConfig.Deployment); client.OnSendingCommand += (_, data) => PrintMessageData(data, "> "); diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs index d9ecf1b2f..626cfd961 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs @@ -23,9 +23,13 @@ public ConversationTests(bool isAsync) : base(isAsync) { } #if !AZURE_OPENAI_GA [Test] - public async Task CanConfigureSession() + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(null)] + public async Task CanConfigureSession(AzureOpenAIClientOptions.ServiceVersion? version) { - RealtimeConversationClient client = GetTestClient(); + RealtimeConversationClient client = GetTestClient(GetTestClientOptions(version)); using RealtimeConversationSession session = await client.StartConversationSessionAsync(CancellationToken); ConversationSessionOptions sessionOptions = new() @@ -91,9 +95,13 @@ List GetReceivedUpdates() where T : ConversationUpdate } [Test] - public async Task TextOnlyWorks() + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(null)] + public async Task TextOnlyWorks(AzureOpenAIClientOptions.ServiceVersion? version) { - RealtimeConversationClient client = GetTestClient(); + RealtimeConversationClient client = GetTestClient(GetTestClientOptions(version)); using RealtimeConversationSession session = await client.StartConversationSessionAsync(CancellationToken); await session.AddItemAsync( ConversationItem.CreateUserMessage(["Hello, world!"]), @@ -166,9 +174,13 @@ await session.AddItemAsync( } [Test] - public async Task ItemManipulationWorks() + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(null)] + public async Task ItemManipulationWorks(AzureOpenAIClientOptions.ServiceVersion? version) { - RealtimeConversationClient client = GetTestClient(); + RealtimeConversationClient client = GetTestClient(GetTestClientOptions(version)); using RealtimeConversationSession session = await client.StartConversationSessionAsync(CancellationToken); await session.ConfigureSessionAsync( @@ -241,9 +253,13 @@ await session.AddItemAsync( } [Test] - public async Task AudioWithToolsWorks() + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(null)] + public async Task AudioWithToolsWorks(AzureOpenAIClientOptions.ServiceVersion? version) { - RealtimeConversationClient client = GetTestClient(); + RealtimeConversationClient client = GetTestClient(GetTestClientOptions(version)); using RealtimeConversationSession session = await client.StartConversationSessionAsync(CancellationToken); ConversationFunctionTool getWeatherTool = new() @@ -339,9 +355,13 @@ public async Task AudioWithToolsWorks() } [Test] - public async Task CanDisableVoiceActivityDetection() + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(null)] + public async Task CanDisableVoiceActivityDetection(AzureOpenAIClientOptions.ServiceVersion? version) { - RealtimeConversationClient client = GetTestClient(); + RealtimeConversationClient client = GetTestClient(GetTestClientOptions(version)); using RealtimeConversationSession session = await client.StartConversationSessionAsync(CancellationToken); await session.ConfigureSessionAsync( @@ -388,9 +408,13 @@ or ConversationResponseStartedUpdate } [Test] - public async Task BadCommandProvidesError() + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(null)] + public async Task BadCommandProvidesError(AzureOpenAIClientOptions.ServiceVersion? version) { - RealtimeConversationClient client = GetTestClient(); + RealtimeConversationClient client = GetTestClient(GetTestClientOptions(version)); using RealtimeConversationSession session = await client.StartConversationSessionAsync(CancellationToken); await session.SendCommandAsync( diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs index 8818daa4a..4c1b9a135 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs @@ -12,10 +12,6 @@ public class FileTests : AoaiTestBase { public FileTests(bool isAsync) : base(isAsync) { - if (new AzureOpenAIClientOptions().Version == "2024-12-01-preview") - { - Assert.Inconclusive("2024-12-01-preview not currently supported for files, fine-tuning, and related routes"); - } } [Test] @@ -23,9 +19,17 @@ public FileTests(bool isAsync) : base(isAsync) public void CanCreateClient() => Assert.That(GetTestClient(), Is.InstanceOf()); [RecordedTest] - public async Task CanUploadAndDeleteFiles() +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task CanUploadAndDeleteFiles(AzureOpenAIClientOptions.ServiceVersion? version) { - OpenAIFileClient client = GetTestClient(); + OpenAIFileClient client = GetTestClient(GetTestClientOptions(version)); OpenAIFile file = await client.UploadFileAsync( BinaryData.FromString("hello, world!"), "test_file_delete_me.txt", @@ -37,10 +41,29 @@ public async Task CanUploadAndDeleteFiles() } [RecordedTest] - public async Task CanListFiles() +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task CanListFiles(AzureOpenAIClientOptions.ServiceVersion? version) { - OpenAIFileClient client = GetTestClient(); + OpenAIFileClient client = GetTestClient(GetTestClientOptions(version)); OpenAIFileCollection files = await client.GetFilesAsync(); Assert.That(files, Has.Count.GreaterThan(0)); } + + private static TestClientOptions GetTestClientOptions(AzureOpenAIClientOptions.ServiceVersion? version) + { +#if !AZURE_OPENAI_GA + if (version != AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview) + { + Assert.Inconclusive("full /files support not yet available after 2024-10-01-preview"); + } +#endif + return version is null ? new TestClientOptions() : new TestClientOptions(version.Value); + } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs index c3f10cf15..3bf0fe8dd 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs @@ -41,9 +41,17 @@ public FineTuningTests(bool isAsync) : base(isAsync) public void CanCreateClient() => Assert.That(GetTestClient(), Is.InstanceOf()); [RecordedTest] - public async Task JobsFineTuning() +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task JobsFineTuning(AzureOpenAIClientOptions.ServiceVersion? version) { - FineTuningClient client = GetTestClient(); + FineTuningClient client = GetTestClient(GetTestClientOptions(version)); int count = 25; @@ -63,10 +71,18 @@ public async Task JobsFineTuning() } [RecordedTest] - public async Task CheckpointsFineTuning() +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task CheckpointsFineTuning(AzureOpenAIClientOptions.ServiceVersion? version) { + FineTuningClient client = GetTestClient(GetTestClientOptions(version)); string fineTunedModel = GetFineTunedModel(); - FineTuningClient client = GetTestClient(); // Check if the model exists by searching all jobs FineTuningJob job = await EnumerateJobsAsync(client) @@ -100,10 +116,18 @@ public async Task CheckpointsFineTuning() } [RecordedTest] - public async Task EventsFineTuning() +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task EventsFineTuning(AzureOpenAIClientOptions.ServiceVersion? version) { + FineTuningClient client = GetTestClient(GetTestClientOptions(version)); string fineTunedModel = GetFineTunedModel(); - FineTuningClient client = GetTestClient(); // Check if the model exists by searching all jobs FineTuningJob job = await EnumerateJobsAsync(client) @@ -138,11 +162,19 @@ public async Task EventsFineTuning() } [RecordedTest] - public async Task CreateAndCancelFineTuning() +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task CreateAndCancelFineTuning(AzureOpenAIClientOptions.ServiceVersion? version) { + FineTuningClient client = GetTestClient(GetTestClientOptions(version)); var fineTuningFile = Assets.FineTuning; - FineTuningClient client = GetTestClient(); OpenAIFileClient fileClient = GetTestClientFrom(client); OpenAIFile uploadedFile = await UploadAndWaitForCompleteOrFail(fileClient, fineTuningFile.RelativePath); @@ -200,11 +232,18 @@ public async Task CreateAndCancelFineTuning() } [RecordedTest] - public async Task CreateAndDeleteFineTuning() +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task CreateAndDeleteFineTuning(AzureOpenAIClientOptions.ServiceVersion? version) { + FineTuningClient client = GetTestClient(GetTestClientOptions(version)); var fineTuningFile = Assets.FineTuning; - - FineTuningClient client = GetTestClient(); OpenAIFileClient fileClient = GetTestClientFrom(client); OpenAIFile uploadedFile = await UploadAndWaitForCompleteOrFail(fileClient, fineTuningFile.RelativePath); @@ -237,12 +276,20 @@ public async Task CreateAndDeleteFineTuning() Assert.True(deleted, "Failed to delete fine tuning model: {0}", job.FineTunedModel); } - [RecordedTest]//AutomaticRecord = false)] + [RecordedTest] +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] [Category("LongRunning")] // CAUTION: This test can take around 10 to 15 *minutes* in live mode to run - public async Task DeployAndChatWithModel() + public async Task DeployAndChatWithModel(AzureOpenAIClientOptions.ServiceVersion? version) { + FineTuningClient client = GetTestClient(GetTestClientOptions(version)); string fineTunedModel = GetFineTunedModel(); - FineTuningClient client = GetTestClient(); AzureDeploymentClient deploymentClient = GetTestClientFrom(client); string? deploymentName = null; @@ -316,6 +363,17 @@ public async Task DeployAndChatWithModel() #region helper methods + private TestClientOptions GetTestClientOptions(AzureOpenAIClientOptions.ServiceVersion? version) + { +#if !AZURE_OPENAI_GA + if (version != AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview) + { + Assert.Inconclusive("fine tuning is not yet fully supported after 2024-10-01-preview"); + } +#endif + return version is null ? new TestClientOptions() : new TestClientOptions(version.Value); + } + private string GetFineTunedModel() { string? model = TestConfig.GetConfig() diff --git a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml index aa0d3d740..301723362 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml @@ -1380,6 +1380,7 @@ components: - 2024-10-01-preview - 2024-10-21 - 2024-12-01-preview + - 2025-01-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml index bf4844b68..29c642bb8 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml @@ -1318,6 +1318,7 @@ components: - 2024-10-01-preview - 2024-10-21 - 2024-12-01-preview + - 2025-01-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml index d8a490f1e..755260df4 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml @@ -1318,6 +1318,7 @@ components: - 2024-10-01-preview - 2024-10-21 - 2024-12-01-preview + - 2025-01-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml index 2463b9fdc..4ec436e96 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml @@ -1353,6 +1353,7 @@ components: - 2024-10-01-preview - 2024-10-21 - 2024-12-01-preview + - 2025-01-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml index 463e02875..724e0fc2b 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml @@ -1389,6 +1389,7 @@ components: - 2024-10-01-preview - 2024-10-21 - 2024-12-01-preview + - 2025-01-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml index 77edf7597..c334c2128 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml @@ -1411,6 +1411,7 @@ components: - 2024-10-01-preview - 2024-10-21 - 2024-12-01-preview + - 2025-01-01-preview description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object diff --git a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml new file mode 100644 index 000000000..14ae18651 --- /dev/null +++ b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml @@ -0,0 +1,3438 @@ +openapi: 3.0.0 +info: + title: Azure OpenAI Service + version: 2025-01-01-preview +tags: + - name: Chat + - name: Images + - name: Assistants +paths: + /deployments/{deploymentId}/images/generations: + post: + operationId: ImageGenerations_Create + parameters: + - name: deploymentId + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/OpenAI.ImagesResponse' + - $ref: '#/components/schemas/AzureOpenAIDalleErrorResponse' + tags: + - Images + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.CreateImageRequest' + /threads/{thread_id}/messages: + post: + operationId: createMessage + summary: Create a message. + parameters: + - name: thread_id + in: path + required: true + description: The ID of the [thread](/docs/api-reference/threads) to create a message for. + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.MessageObject' + default: + description: An unexpected error response. + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.ErrorResponse' + tags: + - Assistants + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAI.CreateMessageRequest' + /{deployment_id}/chat/completions: + post: + operationId: createChatCompletion + parameters: + - name: deployment_id + in: path + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' + tags: + - Chat + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AzureCreateChatCompletionRequest' +security: + - ApiKeyAuth: [] + - OAuth2Auth: + - https://cognitiveservices.azure.com/.default +components: + schemas: + AzureChatCompletionResponseMessage: + type: object + properties: + context: + allOf: + - $ref: '#/components/schemas/AzureChatMessageContext' + description: The Azure-specific context information associated with the chat completion response message. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + description: |- + The extended response model component for chat completion response messages on the Azure OpenAI service. + This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other + information related to retrieval-augmented generation performed. + AzureChatCompletionStreamResponseDelta: + type: object + properties: + context: + allOf: + - $ref: '#/components/schemas/AzureChatMessageContext' + description: The Azure-specific context information associated with the chat completion response message. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' + description: |- + The extended response model for a streaming chat response message on the Azure OpenAI service. + This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other + information related to retrieval-augmented generation performed. + AzureChatDataSource: + type: object + required: + - type + properties: + type: + type: string + description: The differentiating type identifier for the data source. + discriminator: + propertyName: type + mapping: + azure_search: '#/components/schemas/AzureSearchChatDataSource' + azure_cosmos_db: '#/components/schemas/AzureCosmosDBChatDataSource' + elasticsearch: '#/components/schemas/ElasticsearchChatDataSource' + pinecone: '#/components/schemas/PineconeChatDataSource' + mongo_db: '#/components/schemas/MongoDBChatDataSource' + description: |- + A representation of configuration data for a single Azure OpenAI chat data source. + This will be used by a chat completions request that should use Azure OpenAI chat extensions to augment the + response behavior. + The use of this configuration is compatible only with Azure OpenAI. + AzureChatDataSourceAccessTokenAuthenticationOptions: + type: object + required: + - type + - access_token + properties: + type: + type: string + enum: + - access_token + access_token: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceApiKeyAuthenticationOptions: + type: object + required: + - type + - key + properties: + type: + type: string + enum: + - api_key + key: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceAuthenticationOptions: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' + connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' + encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' + access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + AzureChatDataSourceConnectionStringAuthenticationOptions: + type: object + required: + - type + - connection_string + properties: + type: + type: string + enum: + - connection_string + connection_string: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceDeploymentNameVectorizationSource: + type: object + required: + - type + - deployment_name + properties: + type: + type: string + enum: + - deployment_name + description: The type identifier, always 'deployment_name' for this vectorization source type. + deployment_name: + type: string + description: |- + The embedding model deployment to use for vectorization. This deployment must exist within the same Azure OpenAI + resource as the model deployment being used for chat completions. + dimensions: + type: integer + format: int32 + description: |- + The number of dimensions to request on embeddings. + Only supported in 'text-embedding-3' and later models. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: |- + Represents a vectorization source that makes internal service calls against an Azure OpenAI embedding model + deployment. In contrast with the endpoint-based vectorization source, a deployment-name-based vectorization source + must be part of the same Azure OpenAI resource but can be used even in private networks. + AzureChatDataSourceEncodedApiKeyAuthenticationOptions: + type: object + required: + - type + - encoded_api_key + properties: + type: + type: string + enum: + - encoded_api_key + encoded_api_key: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceEndpointVectorizationSource: + type: object + required: + - type + - endpoint + - authentication + properties: + type: + type: string + enum: + - endpoint + description: The type identifier, always 'endpoint' for this vectorization source type. + endpoint: + type: string + format: uri + description: |- + Specifies the resource endpoint URL from which embeddings should be retrieved. + It should be in the format of: + https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. + The api-version query parameter is not allowed. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: |- + The authentication mechanism to use with the endpoint-based vectorization source. + Endpoint authentication supports API key and access token mechanisms. + dimensions: + type: integer + format: int32 + description: |- + The number of dimensions to request on embeddings. + Only supported in 'text-embedding-3' and later models. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: Represents a vectorization source that makes public service calls against an Azure OpenAI embedding model deployment. + AzureChatDataSourceIntegratedVectorizationSource: + type: object + required: + - type + properties: + type: + type: string + enum: + - integrated + description: The type identifier, always 'integrated' for this vectorization source type. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: Represents an integrated vectorization source as defined within the supporting search resource. + AzureChatDataSourceKeyAndKeyIdAuthenticationOptions: + type: object + required: + - type + - key + - key_id + properties: + type: + type: string + enum: + - key_and_key_id + key: + type: string + key_id: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceModelIdVectorizationSource: + type: object + required: + - type + - model_id + properties: + type: + type: string + enum: + - model_id + description: The type identifier, always 'model_id' for this vectorization source type. + model_id: + type: string + description: The embedding model build ID to use for vectorization. + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: |- + Represents a vectorization source that makes service calls based on a search service model ID. + This source type is currently only supported by Elasticsearch. + AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions: + type: object + required: + - type + properties: + type: + type: string + enum: + - system_assigned_managed_identity + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions: + type: object + required: + - type + - managed_identity_resource_id + properties: + type: + type: string + enum: + - user_assigned_managed_identity + managed_identity_resource_id: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceUsernameAndPasswordAuthenticationOptions: + type: object + required: + - type + - username + - password + properties: + type: + type: string + enum: + - username_and_password + username: + type: string + password: + type: string + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' + AzureChatDataSourceVectorizationSource: + type: object + required: + - type + properties: + type: + type: string + description: The differentiating identifier for the concrete vectorization source. + discriminator: + propertyName: type + mapping: + deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' + integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: A representation of a data vectorization source usable as an embedding resource with a data source. + AzureChatMessageContext: + type: object + properties: + intent: + type: string + description: The detected intent from the chat history, which is used to carry conversation context between interactions + citations: + type: array + items: + type: object + properties: + content: + type: string + description: The content of the citation. + title: + type: string + description: The title for the citation. + url: + type: string + description: The URL of the citation. + filepath: + type: string + description: The file path for the citation. + chunk_id: + type: string + description: The chunk ID for the citation. + rerank_score: + type: number + format: double + description: The rerank score for the retrieval. + required: + - content + description: The citations produced by the data retrieval. + all_retrieved_documents: + type: object + properties: + content: + type: string + description: The content of the citation. + title: + type: string + description: The title for the citation. + url: + type: string + description: The URL of the citation. + filepath: + type: string + description: The file path for the citation. + chunk_id: + type: string + description: The chunk ID for the citation. + rerank_score: + type: number + format: double + description: The rerank score for the retrieval. + search_queries: + type: array + items: + type: string + description: The search queries executed to retrieve documents. + data_source_index: + type: integer + format: int32 + description: The index of the data source used for retrieval. + original_search_score: + type: number + format: double + description: The original search score for the retrieval. + filter_reason: + type: string + enum: + - score + - rerank + description: If applicable, an indication of why the document was filtered. + required: + - content + - search_queries + - data_source_index + description: Summary information about documents retrieved by the data retrieval operation. + description: |- + An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using + extension behavior. This includes intent and citation information from the On Your Data feature. + AzureCompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + - completion_tokens_details + - prompt_tokens_details + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + reasoning_tokens: + type: integer + format: int32 + required: + - reasoning_tokens + prompt_tokens_details: + type: object + properties: + cached_tokens: + type: integer + format: int32 + required: + - cached_tokens + AzureContentFilterBlocklistIdResult: + type: object + required: + - id + - filtered + properties: + id: + type: string + description: The ID of the custom blocklist associated with the filtered status. + filtered: + type: boolean + description: Whether the associated blocklist resulted in the content being filtered. + description: |- + A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not + the corresponding blocklist resulted in content being filtered. + AzureContentFilterBlocklistResult: + type: object + required: + - filtered + properties: + filtered: + type: boolean + description: A value indicating whether any of the detailed blocklists resulted in a filtering action. + details: + type: array + items: + type: object + properties: + filtered: + type: boolean + description: A value indicating whether the blocklist produced a filtering action. + id: + type: string + description: The ID of the custom blocklist evaluated. + required: + - filtered + - id + description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. + description: A collection of true/false filtering results for configured custom blocklists. + AzureContentFilterCompletionTextSpan: + type: object + required: + - completion_start_offset + - completion_end_offset + properties: + completion_start_offset: + type: integer + format: int32 + description: Offset of the UTF32 code point which begins the span. + completion_end_offset: + type: integer + format: int32 + description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. + description: A representation of a span of completion text as used by Azure OpenAI content filter results. + AzureContentFilterCompletionTextSpanDetectionResult: + type: object + required: + - filtered + - detected + - details + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + details: + type: array + items: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' + description: Detailed information about the detected completion text spans. + AzureContentFilterDetectionResult: + type: object + required: + - filtered + - detected + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + description: |- + A labeled content filter result item that indicates whether the content was detected and whether the content was + filtered. + AzureContentFilterImagePromptResults: + type: object + required: + - jailbreak + properties: + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + jailbreak: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that describes user prompt injection attacks, where malicious users deliberately exploit + system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content + generation or violations of system-imposed restrictions. + allOf: + - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + description: A content filter result for an image generation operation's input request content. + AzureContentFilterImageResponseResults: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + ungrounded_material: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' + description: A content filter result for a single response item produced by a generative AI system. + AzureContentFilterResultForPrompt: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt associated with the accompanying content filter result categories. + content_filter_results: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + jailbreak: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that describes user prompt injection attacks, where malicious users deliberately exploit + system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content + generation or violations of system-imposed restrictions. + indirect_attack: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that describes attacks on systems powered by Generative AI models that can happen every time + an application processes information that wasn’t directly authored by either the developer of the application or + the user. + required: + - jailbreak + - indirect_attack + description: The content filter category details for the result. + description: A content filter result associated with a single input prompt item into a generative AI system. + AzureContentFilterSeverityResult: + type: object + required: + - filtered + - severity + properties: + filtered: + type: boolean + description: Whether the content severity resulted in a content filtering action. + severity: + type: string + enum: + - safe + - low + - medium + - high + description: The labeled severity of the content. + description: |- + A labeled content filter result item that indicates whether the content was filtered and what the qualitative + severity level of the content was, as evaluated against content filter configuration for the category. + AzureCosmosDBChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_cosmos_db + description: The discriminated type identifier, which is always 'azure_cosmos_db'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + container_name: + type: string + database_name: + type: string + embedding_dependency: + $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + index_name: + type: string + authentication: + $ref: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + fields_mapping: + type: object + properties: + content_fields: + type: array + items: + type: string + vector_fields: + type: array + items: + type: string + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields_separator: + type: string + required: + - content_fields + - vector_fields + required: + - container_name + - database_name + - embedding_dependency + - index_name + - authentication + - fields_mapping + description: The parameter information to control the use of the Azure CosmosDB data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure CosmosDB resource. + AzureCreateChatCompletionRequest: + type: object + required: + - messages + properties: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + data_sources: + type: array + items: + $ref: '#/components/schemas/AzureChatDataSource' + description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. + user_security_context: + $ref: '#/components/schemas/AzureUserSecurityContext' + description: |- + The extended request model for chat completions against the Azure OpenAI service. + This adds the ability to provide data sources for the On Your Data feature. + AzureCreateChatCompletionResponse: + type: object + required: + - id + - choices + - created + - model + - object + - usage + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + usage: + $ref: '#/components/schemas/AzureCompletionUsage' + prompt_filter_results: + type: array + items: + type: object + properties: + prompt_index: + type: integer + format: int32 + description: The index of the input prompt that this content filter result corresponds to. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter results associated with the indexed input prompt. + required: + - prompt_index + - content_filter_results + description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. + description: |- + The extended top-level chat completion response model for the Azure OpenAI service. + This model adds Responsible AI content filter annotations for prompt input. + AzureImage: + type: object + required: + - prompt_filter_results + - content_filter_results + properties: + prompt_filter_results: + $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + content_filter_results: + $ref: '#/components/schemas/AzureContentFilterImageResponseResults' + allOf: + - $ref: '#/components/schemas/OpenAI.Image' + AzureOpenAIChatError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI chat completion request. + AzureOpenAIChatErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIChatError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIDalleError: + type: object + properties: + code: + type: string + description: The distinct, machine-generated identifier for the error. + message: + type: string + description: A human-readable message associated with the error. + param: + type: string + description: If applicable, the request input parameter associated with the error + type: + type: string + description: If applicable, the input line number associated with the error. + inner_error: + type: object + properties: + code: + type: string + enum: + - ResponsibleAIPolicyViolation + description: The code associated with the inner error. + revised_prompt: + type: string + description: If applicable, the modified prompt used for generation. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' + description: The content filter result details associated with the inner error. + description: If applicable, an upstream error that originated this error. + description: The structured representation of an error from an Azure OpenAI image generation request. + AzureOpenAIDalleErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/AzureOpenAIDalleError' + description: A structured representation of an error an Azure OpenAI request. + AzureOpenAIFile: + type: object + required: + - id + - bytes + - created_at + - filename + - object + - purpose + - status + properties: + id: + type: string + description: The file identifier, which can be referenced in the API endpoints. + bytes: + type: integer + format: int32 + nullable: true + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + filename: + type: string + description: The name of the file. + object: + type: string + enum: + - file + description: The object type, which is always `file`. + purpose: + type: string + enum: + - assistants + - assistants_output + - batch + - batch_output + - fine-tune + - fine-tune-results + - vision + description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. + status_details: + type: string + description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + deprecated: true + status: + type: string + enum: + - uploaded + - pending + - running + - processed + - error + - deleting + - deleted + AzureOpenAIServiceApiVersion: + type: string + enum: + - 2024-06-01 + - 2024-08-01-preview + - 2024-09-01-preview + - 2024-10-01-preview + - 2024-10-21 + - 2024-12-01-preview + - 2025-01-01-preview + description: Known service API versions for Azure OpenAI. + AzureSearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - azure_search + description: The discriminated type identifier, which is always 'azure_search'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + description: The absolute endpoint path for the Azure Search resource to use. + index_name: + type: string + description: The name of the index to use, as specified in the Azure Search resource. + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' + description: The authentication mechanism to use with Azure Search. + fields_mapping: + type: object + properties: + title_field: + type: string + description: The name of the index field to use as a title. + url_field: + type: string + description: The name of the index field to use as a URL. + filepath_field: + type: string + description: The name of the index field to use as a filepath. + content_fields: + type: array + items: + type: string + description: The names of index fields that should be treated as content. + content_fields_separator: + type: string + description: The separator pattern that content fields should use. + vector_fields: + type: array + items: + type: string + description: The names of fields that represent vector data. + image_vector_fields: + type: array + items: + type: string + description: The names of fields that represent image vector data. + description: The field mappings to use with the Azure Search resource. + query_type: + type: string + enum: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: + type: string + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + AzureUserSecurityContext: + type: object + properties: + application_name: + type: string + description: The name of the application. Sensitive personal information should not be included in this field. + end_user_id: + type: string + description: This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. + end_user_tenant_id: + type: string + description: The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. + source_ip: + type: string + description: Captures the original client's IP address. + description: User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionTokenLogprobBytesItem: + type: array + items: + type: integer + format: int32 + CompletionUsageCommonBase: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + description: Usage statistics for the completion request. + CreateChatCompletionRequestCommonBase: + type: object + required: + - messages + properties: + messages: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + minItems: 1 + description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + store: + type: boolean + nullable: true + description: |- + Whether or not to store the output of this chat completion request + for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + default: false + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Developer-defined tags and values used for filtering completions + in the [dashboard](https://platform.openai.com/chat-completions). + frequency_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + logit_bias: + type: object + additionalProperties: + type: integer + format: int32 + nullable: true + description: |- + Modify the likelihood of specified tokens appearing in the completion. + + Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + x-oaiTypeLabel: map + default: null + logprobs: + type: boolean + nullable: true + description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + default: false + top_logprobs: + type: integer + format: int32 + nullable: true + minimum: 0 + maximum: 20 + description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + max_tokens: + type: integer + format: int32 + nullable: true + description: |- + The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + + This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + deprecated: true + max_completion_tokens: + type: integer + format: int32 + nullable: true + description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 128 + description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + default: 1 + presence_penalty: + type: number + format: float + nullable: true + minimum: -2 + maximum: 2 + description: |- + Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + + [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + default: 0 + response_format: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + description: |- + An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + + **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + x-oaiExpandable: true + seed: + type: integer + format: int64 + nullable: true + minimum: -9223372036854776000 + maximum: 9223372036854776000 + description: |- + This feature is in Beta. + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + stop: + anyOf: + - type: string + - type: array + items: + type: string + nullable: true + description: Up to 4 sequences where the API will stop generating further tokens. + default: null + stream: + type: boolean + nullable: true + description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' + default: false + stream_options: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' + nullable: true + default: null + temperature: + type: number + format: float + nullable: true + minimum: 0 + maximum: 2 + description: |- + What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + + We generally recommend altering this or `top_p` but not both. + default: 1 + top_p: + type: number + format: float + nullable: true + minimum: 0 + maximum: 1 + description: |- + An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + + We generally recommend altering this or `temperature` but not both. + default: 1 + tools: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTool' + description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + tool_choice: + $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + parallel_tool_calls: + type: boolean + default: true + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + function_call: + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' + description: |- + Deprecated in favor of `tool_choice`. + + Controls which (if any) function is called by the model. + `none` means the model will not call a function and instead generates a message. + `auto` means the model can pick between generating a message or calling a function. + Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + + `none` is the default when no functions are present. `auto` is the default if functions are present. + deprecated: true + x-oaiExpandable: true + functions: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' + minItems: 1 + maxItems: 128 + description: |- + Deprecated in favor of `tools`. + + A list of functions the model may generate JSON inputs for. + deprecated: true + CreateChatCompletionResponseCommonBase: + type: object + required: + - id + - choices + - created + - model + - object + properties: + id: + type: string + description: A unique identifier for the chat completion. + choices: + type: array + items: + type: object + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + required: + - finish_reason + - index + - message + - logprobs + description: A list of chat completion choices. Can be more than one if `n` is greater than 1. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the chat completion was created. + model: + type: string + description: The model used for the chat completion. + service_tier: + type: string + enum: + - scale + - default + nullable: true + description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + system_fingerprint: + type: string + description: |- + This fingerprint represents the backend configuration that the model runs with. + + Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + object: + type: string + enum: + - chat.completion + description: The object type, which is always `chat.completion`. + description: Represents a chat completion response returned by model, based on the provided input. + CreateMessageRequestAttachments: + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools + ElasticsearchChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - elasticsearch + description: The discriminated type identifier, which is always 'elasticsearch'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + format: uri + index_name: + type: string + authentication: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' + - $ref: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' + fields_mapping: + type: object + properties: + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields: + type: array + items: + type: string + content_fields_separator: + type: string + vector_fields: + type: array + items: + type: string + query_type: + type: string + enum: + - simple + - vector + embedding_dependency: + $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Elasticsearch data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + MessageObjectAttachments: + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + MongoDBChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - mongo_db + description: The discriminated type identifier, which is always 'mongo_db'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + endpoint: + type: string + description: The name of the MongoDB cluster endpoint. + database_name: + type: string + description: The name of the MongoDB database. + collection_name: + type: string + description: The name of the MongoDB collection. + app_name: + type: string + description: The name of the MongoDB application. + index_name: + type: string + description: The name of the MongoDB index. + authentication: + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' + description: |- + The authentication mechanism to use with Pinecone. + Supported authentication mechanisms for Pinecone include: username and password. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + description: |- + The vectorization source to use as an embedding dependency for the MongoDB data source. + Supported vectorization sources for MongoDB include: endpoint, deployment name. + fields_mapping: + type: object + properties: + content_fields: + type: array + items: + type: string + vector_fields: + type: array + items: + type: string + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields_separator: + type: string + required: + - content_fields + - vector_fields + description: |- + Field mappings to apply to data used by the MongoDB data source. + Note that content and vector field mappings are required for MongoDB. + required: + - endpoint + - database_name + - collection_name + - app_name + - index_name + - authentication + - embedding_dependency + - fields_mapping + description: The parameter information to control the use of the MongoDB data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + OpenAI.AssistantToolDefinition: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + file_search: '#/components/schemas/OpenAI.AssistantToolsFileSearch' + function: '#/components/schemas/OpenAI.AssistantToolsFunction' + OpenAI.AssistantToolsCode: + type: object + required: + - type + properties: + type: + type: string + enum: + - code_interpreter + description: 'The type of tool being defined: `code_interpreter`' + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.AssistantToolsFileSearch: + type: object + required: + - type + properties: + type: + type: string + enum: + - file_search + description: 'The type of tool being defined: `file_search`' + file_search: + type: object + properties: + max_num_results: + type: integer + format: int32 + minimum: 1 + maximum: 50 + description: |- + The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + ranking_options: + $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' + description: Overrides for the file search tool. + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.AssistantToolsFileSearchTypeOnly: + type: object + required: + - type + properties: + type: + type: string + enum: + - file_search + description: 'The type of tool being defined: `file_search`' + OpenAI.AssistantToolsFunction: + type: object + required: + - type + - function + properties: + type: + type: string + enum: + - function + description: 'The type of tool being defined: `function`' + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.ChatCompletionFunctionCallOption: + type: object + required: + - name + properties: + name: + type: string + description: The name of the function to call. + description: 'Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.' + OpenAI.ChatCompletionFunctions: + type: object + required: + - name + properties: + description: + type: string + description: A description of what the function does, used by the model to choose when and how to call the function. + name: + type: string + description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/OpenAI.FunctionParameters' + deprecated: true + OpenAI.ChatCompletionMessageToolCall: + type: object + required: + - id + - type + - function + properties: + id: + type: string + description: The ID of the tool call. + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + arguments: + type: string + description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. + required: + - name + - arguments + description: The function that the model called. + OpenAI.ChatCompletionMessageToolCallChunk: + type: object + required: + - index + properties: + index: + type: integer + format: int32 + id: + type: string + description: The ID of the tool call. + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + arguments: + type: string + description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. + OpenAI.ChatCompletionNamedToolChoice: + type: object + required: + - type + - function + properties: + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + required: + - name + description: Specifies a tool the model should use. Use to force the model to call a specific function. + OpenAI.ChatCompletionRequestAssistantMessage: + type: object + required: + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessageContentPart' + nullable: true + description: The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. + x-oaiExpandable: true + refusal: + type: string + nullable: true + description: The refusal message by the assistant. + role: + type: string + enum: + - assistant + description: The role of the messages author, in this case `assistant`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + nullable: true + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestAssistantMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestFunctionMessage: + type: object + required: + - role + - content + - name + properties: + role: + type: string + enum: + - function + description: The role of the messages author, in this case `function`. + content: + type: string + nullable: true + description: The contents of the function message. + name: + type: string + description: The name of the function to call. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + deprecated: true + OpenAI.ChatCompletionRequestMessage: + type: object + required: + - role + properties: + role: + type: string + description: The role of the author of this message. + discriminator: + propertyName: role + mapping: + system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' + assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' + tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' + function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartImage: + type: object + required: + - type + - image_url + properties: + type: + type: string + enum: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: Either a URL of the image or the base64 encoded image data. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + default: auto + required: + - url + OpenAI.ChatCompletionRequestMessageContentPartRefusal: + type: object + required: + - type + - refusal + properties: + type: + type: string + enum: + - refusal + description: The type of the content part. + refusal: + type: string + description: The refusal message generated by the model. + OpenAI.ChatCompletionRequestMessageContentPartText: + type: object + required: + - type + - text + properties: + type: + type: string + enum: + - text + description: The type of the content part. + text: + type: string + description: The text content. + OpenAI.ChatCompletionRequestSystemMessage: + type: object + required: + - content + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + description: The contents of the system message. + role: + type: string + enum: + - system + description: The role of the messages author, in this case `system`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestSystemMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestToolMessage: + type: object + required: + - role + - content + - tool_call_id + properties: + role: + type: string + enum: + - tool + description: The role of the messages author, in this case `tool`. + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' + description: The contents of the tool message. + tool_call_id: + type: string + description: Tool call that this message is responding to. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestToolMessageContentPart: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + x-oaiExpandable: true + OpenAI.ChatCompletionRequestUserMessage: + type: object + required: + - content + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' + description: The contents of the user message. + x-oaiExpandable: true + role: + type: string + enum: + - user + description: The role of the messages author, in this case `user`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + OpenAI.ChatCompletionRequestUserMessageContentPart: + anyOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + x-oaiExpandable: true + OpenAI.ChatCompletionResponseMessage: + type: object + required: + - content + - refusal + - role + properties: + content: + type: string + nullable: true + description: The contents of the message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + tool_calls: + $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' + role: + type: string + enum: + - assistant + description: The role of the author of this message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + required: + - name + - arguments + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + description: A chat completion message generated by the model. + OpenAI.ChatCompletionStreamOptions: + type: object + properties: + include_usage: + type: boolean + description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' + description: 'Options for streaming response. Only set this when you set `stream: true`.' + OpenAI.ChatCompletionStreamResponseDelta: + type: object + properties: + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. + description: A chat completion delta generated by streamed model responses. + OpenAI.ChatCompletionTokenLogprob: + type: object + required: + - token + - logprob + - bytes + - top_logprobs + properties: + token: + type: string + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + top_logprobs: + type: array + items: + type: object + properties: + token: + type: string + description: The token. + logprob: + type: number + format: float + description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + bytes: + type: array + items: + type: integer + format: int32 + nullable: true + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + required: + - token + - logprob + - bytes + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. + OpenAI.ChatCompletionTool: + type: object + required: + - type + - function + properties: + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + function: + $ref: '#/components/schemas/OpenAI.FunctionObject' + OpenAI.ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - auto + - required + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' + description: |- + Controls which (if any) tool is called by the model. + `none` means the model will not call any tool and instead generates a message. + `auto` means the model can pick between generating a message or calling one or more tools. + `required` means the model must call one or more tools. + Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + + `none` is the default when no tools are present. `auto` is the default if tools are present. + x-oaiExpandable: true + OpenAI.ChatResponseFormat: + type: object + required: + - type + properties: + type: + type: string + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/OpenAI.ChatResponseFormatText' + json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' + json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' + OpenAI.ChatResponseFormatJsonObject: + type: object + required: + - type + properties: + type: + type: string + enum: + - json_object + description: 'The type of response format being defined: `json_object`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatJsonSchema: + type: object + required: + - type + - json_schema + properties: + type: + type: string + enum: + - json_schema + description: 'The type of response format being defined: `json_schema`' + json_schema: + type: object + properties: + description: + type: string + description: A description of what the response format is for, used by the model to determine how to respond in the format. + name: + type: string + description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + default: false + required: + - name + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.ChatResponseFormatText: + type: object + required: + - type + properties: + type: + type: string + enum: + - text + description: 'The type of response format being defined: `text`' + allOf: + - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CreateImageRequest: + type: object + required: + - prompt + properties: + prompt: + type: string + description: A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`. + model: + anyOf: + - type: string + - type: string + enum: + - dall-e-2 + - dall-e-3 + nullable: true + description: The model to use for image generation. + x-oaiTypeLabel: string + default: dall-e-2 + n: + type: integer + format: int32 + nullable: true + minimum: 1 + maximum: 10 + description: The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported. + default: 1 + quality: + type: string + enum: + - standard + - hd + description: The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`. + default: standard + response_format: + type: string + enum: + - url + - b64_json + nullable: true + description: The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. + default: url + size: + type: string + enum: + - 256x256 + - 512x512 + - 1024x1024 + - 1792x1024 + - 1024x1792 + nullable: true + description: The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3` models. + default: 1024x1024 + style: + type: string + enum: + - vivid + - natural + nullable: true + description: The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`. + default: vivid + user: + type: string + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + OpenAI.CreateMessageRequest: + type: object + required: + - role + - content + properties: + role: + type: string + enum: + - user + - assistant + description: |- + The role of the entity that is creating the message. Allowed values include: + - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. + - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContent' + x-oaiExpandable: true + attachments: + type: object + allOf: + - $ref: '#/components/schemas/CreateMessageRequestAttachments' + nullable: true + description: A list of files attached to the message, and the tools they should be added to. + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + x-oaiTypeLabel: map + OpenAI.Error: + type: object + required: + - code + - message + - param + - type + properties: + code: + type: string + nullable: true + message: + type: string + param: + type: string + nullable: true + type: + type: string + OpenAI.ErrorResponse: + type: object + required: + - error + properties: + error: + $ref: '#/components/schemas/OpenAI.Error' + OpenAI.FileSearchRankingOptions: + type: object + required: + - score_threshold + properties: + ranker: + type: string + enum: + - auto + - default_2024_08_21 + description: The ranker to use for the file search. If not specified will use the `auto` ranker. + score_threshold: + type: number + format: float + minimum: 0 + maximum: 1 + description: The score threshold for the file search. All values must be a floating point number between 0 and 1. + description: |- + The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + + See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + OpenAI.FunctionObject: + type: object + required: + - name + properties: + description: + type: string + description: A description of what the function does, used by the model to choose when and how to call the function. + name: + type: string + description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/OpenAI.FunctionParameters' + strict: + type: boolean + nullable: true + description: Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling). + default: false + OpenAI.FunctionParameters: + type: object + additionalProperties: {} + description: |- + The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + + Omitting `parameters` defines a function with an empty parameter list. + OpenAI.Image: + type: object + properties: + b64_json: + type: string + format: base64 + description: The base64-encoded JSON of the generated image, if `response_format` is `b64_json`. + url: + type: string + format: uri + description: The URL of the generated image, if `response_format` is `url` (default). + revised_prompt: + type: string + description: The prompt that was used to generate the image, if there was any revision to the prompt. + description: Represents the url or the content of an image generated by the OpenAI API. + OpenAI.ImagesResponse: + type: object + required: + - created + - data + properties: + created: + type: integer + format: unixtime + data: + type: array + items: + $ref: '#/components/schemas/OpenAI.Image' + OpenAI.MessageContent: + type: object + description: Represents a single piece of content in an Assistants API message. + OpenAI.MessageContentImageFileObject: + type: object + required: + - type + - image_file + properties: + type: + type: string + enum: + - image_file + description: Always `image_file`. + image_file: + type: object + properties: + file_id: + type: string + description: The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. + default: auto + required: + - file_id + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: References an image [File](/docs/api-reference/files) in the content of a message. + OpenAI.MessageContentImageUrlObject: + type: object + required: + - type + - image_url + properties: + type: + type: string + enum: + - image_url + description: The type of the content part. + image_url: + type: object + properties: + url: + type: string + format: uri + description: 'The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.' + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + default: auto + required: + - url + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: References an image URL in the content of a message. + OpenAI.MessageContentRefusalObject: + type: object + required: + - type + - refusal + properties: + type: + type: string + enum: + - refusal + description: Always `refusal`. + refusal: + type: string + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The refusal content generated by the assistant. + OpenAI.MessageContentTextAnnotationsFileCitationObject: + type: object + required: + - type + - text + - file_citation + - start_index + - end_index + properties: + type: + type: string + enum: + - file_citation + description: Always `file_citation`. + text: + type: string + description: The text in the message content that needs to be replaced. + file_citation: + type: object + properties: + file_id: + type: string + description: The ID of the specific File the citation is from. + required: + - file_id + start_index: + type: integer + format: int32 + minimum: 0 + end_index: + type: integer + format: int32 + minimum: 0 + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + description: A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + OpenAI.MessageContentTextAnnotationsFilePathObject: + type: object + required: + - type + - text + - file_path + - start_index + - end_index + properties: + type: + type: string + enum: + - file_path + description: Always `file_path`. + text: + type: string + description: The text in the message content that needs to be replaced. + file_path: + type: object + properties: + file_id: + type: string + description: The ID of the file that was generated. + required: + - file_id + start_index: + type: integer + format: int32 + minimum: 0 + end_index: + type: integer + format: int32 + minimum: 0 + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + description: A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + OpenAI.MessageContentTextObject: + type: object + required: + - type + - text + properties: + type: + type: string + enum: + - text + description: Always `text`. + text: + type: object + properties: + value: + type: string + description: The data that makes up the text. + annotations: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + x-oaiExpandable: true + required: + - value + - annotations + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The text content that is part of a message. + OpenAI.MessageContentTextObjectAnnotation: + type: object + required: + - type + properties: + type: + type: string + description: The discriminated type identifier for the content item. + discriminator: + propertyName: type + mapping: + file_citation: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFileCitationObject' + file_path: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFilePathObject' + OpenAI.MessageObject: + type: object + required: + - id + - object + - created_at + - thread_id + - status + - incomplete_details + - completed_at + - incomplete_at + - role + - content + - assistant_id + - run_id + - attachments + - metadata + properties: + id: + type: string + description: The identifier, which can be referenced in API endpoints. + object: + type: string + enum: + - thread.message + description: The object type, which is always `thread.message`. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the message was created. + thread_id: + type: string + description: The [thread](/docs/api-reference/threads) ID that this message belongs to. + status: + type: string + enum: + - in_progress + - incomplete + - completed + description: The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + incomplete_details: + type: object + properties: + reason: + type: string + enum: + - content_filter + - max_tokens + - run_cancelled + - run_expired + - run_failed + description: The reason the message is incomplete. + required: + - reason + nullable: true + description: On an incomplete message, details about why the message is incomplete. + completed_at: + type: integer + format: unixtime + nullable: true + description: The Unix timestamp (in seconds) for when the message was completed. + incomplete_at: + type: integer + format: unixtime + nullable: true + description: The Unix timestamp (in seconds) for when the message was marked as incomplete. + role: + type: string + enum: + - user + - assistant + description: The entity that produced the message. One of `user` or `assistant`. + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContent' + description: The content of the message in array of text and/or images. + x-oaiExpandable: true + readOnly: true + assistant_id: + type: string + nullable: true + description: If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. + run_id: + type: string + nullable: true + description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. + attachments: + type: object + allOf: + - $ref: '#/components/schemas/MessageObjectAttachments' + nullable: true + description: A list of files attached to the message, and the tools they were added to. + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + x-oaiTypeLabel: map + readOnly: true + description: Represents a message within a [thread](/docs/api-reference/threads). + OpenAI.MessageRequestContentTextObject: + type: object + required: + - type + - text + properties: + type: + type: string + enum: + - text + description: Always `text`. + text: + type: string + description: Text content to be sent to the model + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The text content that is part of a message. + OpenAI.ResponseFormatJsonSchemaSchema: + type: object + additionalProperties: {} + description: The schema for the response format, described as a JSON Schema object. + OpenAIFileWithOmittedProperties: + type: object + required: + - id + - bytes + - created_at + - filename + - object + - purpose + properties: + id: + type: string + description: The file identifier, which can be referenced in the API endpoints. + bytes: + type: integer + format: int32 + nullable: true + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + filename: + type: string + description: The name of the file. + object: + type: string + enum: + - file + description: The object type, which is always `file`. + purpose: + type: string + enum: + - assistants + - assistants_output + - batch + - batch_output + - fine-tune + - fine-tune-results + - vision + description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. + status_details: + type: string + description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + deprecated: true + description: The `File` object represents a document that has been uploaded to OpenAI. + PineconeChatDataSource: + type: object + required: + - type + - parameters + properties: + type: + type: string + enum: + - pinecone + description: The discriminated type identifier, which is always 'pinecone'. + parameters: + type: object + properties: + top_n_documents: + type: integer + format: int32 + description: The configured number of documents to feature in the query. + in_scope: + type: boolean + description: Whether queries should be restricted to use of the indexed data. + strictness: + type: integer + format: int32 + minimum: 1 + maximum: 5 + description: |- + The configured strictness of the search relevance filtering. + Higher strictness will increase precision but lower recall of the answer. + max_search_queries: + type: integer + format: int32 + description: |- + The maximum number of rewritten queries that should be sent to the search provider for a single user message. + By default, the system will make an automatic determination. + allow_partial_result: + type: boolean + description: |- + If set to true, the system will allow partial search results to be used and the request will fail if all + partial queries fail. If not specified or specified as false, the request will fail if any search query fails. + default: false + include_contexts: + type: array + items: + type: string + enum: + - citations + - intent + - all_retrieved_documents + maxItems: 3 + description: |- + The output context properties to include on the response. + By default, citations and intent will be requested. + default: + - citations + - intent + environment: + type: string + description: The environment name to use with Pinecone. + index_name: + type: string + description: The name of the Pinecone database index to use. + authentication: + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' + description: |- + The authentication mechanism to use with Pinecone. + Supported authentication mechanisms for Pinecone include: API key. + embedding_dependency: + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' + description: |- + The vectorization source to use as an embedding dependency for the Pinecone data source. + Supported vectorization sources for Pinecone include: deployment name. + fields_mapping: + type: object + properties: + content_fields: + type: array + items: + type: string + title_field: + type: string + url_field: + type: string + filepath_field: + type: string + content_fields_separator: + type: string + required: + - content_fields + description: |- + Field mappings to apply to data used by the Pinecone data source. + Note that content field mappings are required for Pinecone. + required: + - environment + - index_name + - authentication + - embedding_dependency + - fields_mapping + description: The parameter information to control the use of the Pinecone data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + securitySchemes: + ApiKeyAuth: + type: apiKey + in: header + name: api-key + OAuth2Auth: + type: oauth2 + flows: + implicit: + authorizationUrl: https://login.microsoftonline.com/common/oauth2/v2.0/authorize + scopes: + https://cognitiveservices.azure.com/.default: '' +servers: + - url: '{endpoint}/openai' + description: Azure OpenAI APIs for completions and search + variables: + endpoint: + default: '' + description: |- + Supported Cognitive Services endpoints (protocol and hostname, for example: + https://westus.api.cognitive.microsoft.com). diff --git a/.typespec.azure/chat/models.request.tsp b/.typespec.azure/chat/models.request.tsp index f31d1648e..31ee40aee 100644 --- a/.typespec.azure/chat/models.request.tsp +++ b/.typespec.azure/chat/models.request.tsp @@ -26,7 +26,7 @@ model AzureCreateChatCompletionRequest { */ data_sources?: AzureChatDataSource[]; - @added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) + @added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) user_security_context?: AzureUserSecurityContext; } @@ -329,7 +329,7 @@ alias AzureChatDataSourceCommonParameters = { /** * User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. */ -@added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model AzureUserSecurityContext { /** The name of the application. Sensitive personal information should not be included in this field. */ application_name?: string; diff --git a/.typespec.azure/common/models.rai.tsp b/.typespec.azure/common/models.rai.tsp index e53940458..4b5e2ebd4 100644 --- a/.typespec.azure/common/models.rai.tsp +++ b/.typespec.azure/common/models.rai.tsp @@ -59,7 +59,7 @@ model AzureContentFilterCompletionTextSpan { @added(AzureOpenAIServiceApiVersion.v2024_10_01_preview) @removed(AzureOpenAIServiceApiVersion.v2024_10_21) -@added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model AzureContentFilterCompletionTextSpanDetectionResult { ...AzureContentFilterDetectionResult; @@ -68,7 +68,7 @@ model AzureContentFilterCompletionTextSpanDetectionResult { */ @added(AzureOpenAIServiceApiVersion.v2024_10_01_preview) @removed(AzureOpenAIServiceApiVersion.v2024_10_21) - @added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) + @added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) details: AzureContentFilterCompletionTextSpan[]; } @@ -173,7 +173,7 @@ model AzureContentFilterResultForChoice { @added(AzureOpenAIServiceApiVersion.v2024_10_01_preview) @removed(AzureOpenAIServiceApiVersion.v2024_10_21) - @added(AzureOpenAIServiceApiVersion.v2024_12_01_Preview) + @added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) ungrounded_material?: AzureContentFilterCompletionTextSpanDetectionResult; } diff --git a/.typespec.azure/main.tsp b/.typespec.azure/main.tsp index ef9223a44..d18dfa0c2 100644 --- a/.typespec.azure/main.tsp +++ b/.typespec.azure/main.tsp @@ -80,5 +80,10 @@ enum AzureOpenAIServiceApiVersion { /** * The 2024-12-01-preview service API version label. */ - v2024_12_01_Preview: "2024-12-01-preview", + v2024_12_01_preview: "2024-12-01-preview", + + /** + * The 2025-01-01-preview service API version label. + */ + v2025_01_01_preview: "2025-01-01-preview", } From 7bf73a8cb2f651406b706365c8480625eb32d638 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Tue, 21 Jan 2025 17:35:48 -0800 Subject: [PATCH 17/44] minor changelog update; test assets repushed --- .../sdk/openai/Azure.AI.OpenAI/CHANGELOG.md | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md index 85eaefe45..9a537d2e1 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md @@ -1,6 +1,14 @@ # Release History -## 2.1.0 (Unreleased) +## 2.2.0-beta.1 (Unreleased) + +This preview release aligns with the corresponding `2.2.0` beta of `OpenAI` and the `2025-01-01-Preview` Azure OpenAI Service API version. + +New features include: + +- To be filled + +## 2.1.0 (2024-12-05) This GA library release aligns functionality with the latest `2024-10-21` stable service API label. @@ -39,10 +47,6 @@ The `2024-10-21` service API label introduces stable support for batch chat comp This update brings compatibility with the Azure OpenAI `2024-10-01-preview` service API version as well as the `2.1.0-beta.2` release of the `OpenAI` library. -### Breaking Changes - -- `[Experimental]` `ChatCitation` and `ChatRetrievedDocument` have each replaced the `Uri` property of type `System.Uri` with a `string` property named `Url`. This aligns with the REST specification and accounts for the wire value of `url` not always providing a valid RFC 3986 identifier [[azure-sdk-for-net \#46793](https://github.com/Azure/azure-sdk-for-net/issues/46793)] - ### Features Added - The included update via `2024-09-01-preview` brings AOAI support for streaming token usage in chat completions; `Usage` is now automatically populated in `StreamingChatCompletionUpdate` instances. @@ -50,21 +54,14 @@ This update brings compatibility with the Azure OpenAI `2024-10-01-preview` serv - Note 2: this feature is not yet compatible when using image input (a `ChatMessageContentPart` of `Kind` `Image`) - `2024-10-01-preview` further adds support for ungrounded content detection in chat completion content filter results via the `UngroundedMaterial` property on `ResponseContentFilterResult`, as retrieved from a chat completion via the `GetResponseContentFilterResult()` extension method. -Via `OpenAI 2.0.0-beta.2`: +## Breaking Changes -- Made improvements to the experimental Realtime API. Please note this features area is currently under rapid development and not all changes may be reflected here. - - Several types have been renamed for consistency and clarity. - - ConversationRateLimitsUpdate (previously ConversationRateLimitsUpdatedUpdate) now includes named RequestDetails and TokenDetails properties, mapping to the corresponding named items in the underlying rate_limits command payload. +- `[Experimental]` `ChatCitation` and `ChatRetrievedDocument` have each replaced the `Uri` property of type `System.Uri` with a `string` property named `Url`. This aligns with the REST specification and accounts for the wire value of `url` not always providing a valid RFC 3986 identifier [[azure-sdk-for-net \#46793](https://github.com/Azure/azure-sdk-for-net/issues/46793)] -### Bugs Fixed +## Bugs Fixed -- Addressed an HTTP 401 issue that caused certain connection retry attempts, such as those triggered for HTTP 429 rate limiting errors, to sometimes generate a malformed request with multiple `Authorization` headers that would then be rejected. [#46401](https://github.com/Azure/azure-sdk-for-net/pull/46401) - Addressed an issue that caused `ChatCitation` and `ChatRetrievedDocument` to sometimes throw on deserialization, specifically when a returned value in the `url` JSON field was not populated with an RFC 3986 compliant identifier for `System.Uri` [[azure-sdk-for-net \#46793](https://github.com/Azure/azure-sdk-for-net/issues/46793)] -Via `OpenAI 2.0.0-beta.2`: - -- Fixed serialization and deserialization of ConversationToolChoice literal values (such as "required"). - ## 2.1.0-beta.1 (2024-10-01) Relative to the prior GA release, this update restores preview surfaces, retargeting to the latest `2024-08-01-preview` service `api-version` label. It also brings early support for the newly-announced `/realtime` capabilities with `gpt-4o-realtime-preview`. You can read more about Azure OpenAI support for `/realtime` in the annoucement post here: https://azure.microsoft.com/blog/announcing-new-products-and-features-for-azure-openai-service-including-gpt-4o-realtime-preview-with-audio-and-speech-capabilities/ @@ -634,7 +631,7 @@ management, and align with the Azure SDK guidelines. - In contrast to other capabilities, DALL-E image generation does not require explicit creation or specification of a deployment or model. Its surface as such does not include this concept. - Functions for chat completions are now supported: see [OpenAI's blog post on the topic](https://openai.com/blog/function-calling-and-other-api-updates) for much more detail. - A list of `FunctionDefinition` objects may be populated on `ChatCompletionsOptions` via its `Functions` property. These definitions include a name and description together with a serialized JSON Schema representation of its parameters; these parameters can be generated easily via `BinaryData.FromObjectAsJson` with dynamic objects -- see the README for example usage. - - **NOTE**: Chat Functions requires a minimum of the `-0613` model versions for `gpt-4` and `gpt-3.5-turbo`/`gpt-35-turbo`. Please ensure you're using these later model versions, as Functions are not supported with older model revisions. For Azure OpenAI, you can update a deployment's model version or create a new model deployment with an updated version via the Azure AI Studio interface, also accessible through Azure Portal. + - **NOTE**: Chat Functions requires a minimum of the `-0613` model versions for `gpt-4` and `gpt-3.5-turbo`/`gpt-35-turbo`. Please ensure you're using these later model versions, as Functions are not supported with older model revisions. For Azure OpenAI, you can update a deployment's model version or create a new model deployment with an updated version via the Azure AI Foundry interface, also accessible through Azure Portal. - (Azure OpenAI specific) Completions and Chat Completions responses now include embedded content filter annotations for prompts and responses - A new `Azure.AI.OpenAI.AzureOpenAIModelFactory` is now present for mocking. From 8a6a278727fe212bb2933e94c15a334fcc72cdfd Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 22 Jan 2025 11:13:07 -0800 Subject: [PATCH 18/44] fix realtime conversation token usage --- .dotnet/api/OpenAI.netstandard2.0.cs | 4 +- .../ConversationTokenUsage.cs | 16 +++++++ .../ConversationTokenUsage.Serialization.cs | 44 +++++++++---------- .../Models/ConversationTokenUsage.cs | 10 ++--- .dotnet/src/Generated/OpenAIModelFactory.cs | 6 +-- 5 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 .dotnet/src/Custom/RealtimeConversation/ConversationTokenUsage.cs diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 73685dee0..6990fde32 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -2558,10 +2558,10 @@ public class ConversationStatusDetails : IJsonModel, public static implicit operator BinaryContent(ConversationStatusDetails conversationStatusDetails); } public class ConversationTokenUsage : IJsonModel, IPersistableModel { + public int InputTokenCount { get; } public ConversationInputTokenUsageDetails InputTokenDetails { get; } - public int? InputTokens { get; } + public int OutputTokenCount { get; } public ConversationOutputTokenUsageDetails OutputTokenDetails { get; } - public int? OutputTokens { get; } public int? TotalTokens { get; } public static explicit operator ConversationTokenUsage(ClientResult result); public static implicit operator BinaryContent(ConversationTokenUsage conversationTokenUsage); diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationTokenUsage.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationTokenUsage.cs new file mode 100644 index 000000000..18ab0462b --- /dev/null +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationTokenUsage.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.RealtimeConversation; + +public partial class ConversationTokenUsage +{ + // CUSTOM: Renamed, nullability removed + [CodeGenMember("InputTokens")] + public int InputTokenCount { get; } + + // CUSTOM: Renamed, nullability removed + [CodeGenMember("OutputTokens")] + public int OutputTokenCount { get; } +} \ No newline at end of file diff --git a/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs b/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs index c1525aa87..d67cd3b3a 100644 --- a/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs @@ -32,16 +32,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("total_tokens"u8); writer.WriteNumberValue(TotalTokens.Value); } - if (Optional.IsDefined(InputTokens) && _additionalBinaryDataProperties?.ContainsKey("input_tokens") != true) - { - writer.WritePropertyName("input_tokens"u8); - writer.WriteNumberValue(InputTokens.Value); - } - if (Optional.IsDefined(OutputTokens) && _additionalBinaryDataProperties?.ContainsKey("output_tokens") != true) - { - writer.WritePropertyName("output_tokens"u8); - writer.WriteNumberValue(OutputTokens.Value); - } if (Optional.IsDefined(InputTokenDetails) && _additionalBinaryDataProperties?.ContainsKey("input_token_details") != true) { writer.WritePropertyName("input_token_details"u8); @@ -52,6 +42,16 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("output_token_details"u8); writer.WriteObjectValue(OutputTokenDetails, options); } + if (_additionalBinaryDataProperties?.ContainsKey("input_tokens") != true) + { + writer.WritePropertyName("input_tokens"u8); + writer.WriteNumberValue(InputTokenCount); + } + if (_additionalBinaryDataProperties?.ContainsKey("output_tokens") != true) + { + writer.WritePropertyName("output_tokens"u8); + writer.WriteNumberValue(OutputTokenCount); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -93,10 +93,10 @@ internal static ConversationTokenUsage DeserializeConversationTokenUsage(JsonEle return null; } int? totalTokens = default; - int? inputTokens = default; - int? outputTokens = default; ConversationInputTokenUsageDetails inputTokenDetails = default; ConversationOutputTokenUsageDetails outputTokenDetails = default; + int inputTokenCount = default; + int outputTokenCount = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -109,40 +109,40 @@ internal static ConversationTokenUsage DeserializeConversationTokenUsage(JsonEle totalTokens = prop.Value.GetInt32(); continue; } - if (prop.NameEquals("input_tokens"u8)) + if (prop.NameEquals("input_token_details"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inputTokens = prop.Value.GetInt32(); + inputTokenDetails = ConversationInputTokenUsageDetails.DeserializeConversationInputTokenUsageDetails(prop.Value, options); continue; } - if (prop.NameEquals("output_tokens"u8)) + if (prop.NameEquals("output_token_details"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - outputTokens = prop.Value.GetInt32(); + outputTokenDetails = ConversationOutputTokenUsageDetails.DeserializeConversationOutputTokenUsageDetails(prop.Value, options); continue; } - if (prop.NameEquals("input_token_details"u8)) + if (prop.NameEquals("input_tokens"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inputTokenDetails = ConversationInputTokenUsageDetails.DeserializeConversationInputTokenUsageDetails(prop.Value, options); + inputTokenCount = prop.Value.GetInt32(); continue; } - if (prop.NameEquals("output_token_details"u8)) + if (prop.NameEquals("output_tokens"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - outputTokenDetails = ConversationOutputTokenUsageDetails.DeserializeConversationOutputTokenUsageDetails(prop.Value, options); + outputTokenCount = prop.Value.GetInt32(); continue; } if (true) @@ -152,10 +152,10 @@ internal static ConversationTokenUsage DeserializeConversationTokenUsage(JsonEle } return new ConversationTokenUsage( totalTokens, - inputTokens, - outputTokens, inputTokenDetails, outputTokenDetails, + inputTokenCount, + outputTokenCount, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/ConversationTokenUsage.cs b/.dotnet/src/Generated/Models/ConversationTokenUsage.cs index fdeb570ae..a5556fa21 100644 --- a/.dotnet/src/Generated/Models/ConversationTokenUsage.cs +++ b/.dotnet/src/Generated/Models/ConversationTokenUsage.cs @@ -15,22 +15,18 @@ internal ConversationTokenUsage() { } - internal ConversationTokenUsage(int? totalTokens, int? inputTokens, int? outputTokens, ConversationInputTokenUsageDetails inputTokenDetails, ConversationOutputTokenUsageDetails outputTokenDetails, IDictionary additionalBinaryDataProperties) + internal ConversationTokenUsage(int? totalTokens, ConversationInputTokenUsageDetails inputTokenDetails, ConversationOutputTokenUsageDetails outputTokenDetails, int inputTokenCount, int outputTokenCount, IDictionary additionalBinaryDataProperties) { TotalTokens = totalTokens; - InputTokens = inputTokens; - OutputTokens = outputTokens; InputTokenDetails = inputTokenDetails; OutputTokenDetails = outputTokenDetails; + InputTokenCount = inputTokenCount; + OutputTokenCount = outputTokenCount; _additionalBinaryDataProperties = additionalBinaryDataProperties; } public int? TotalTokens { get; } - public int? InputTokens { get; } - - public int? OutputTokens { get; } - public ConversationInputTokenUsageDetails InputTokenDetails { get; } public ConversationOutputTokenUsageDetails OutputTokenDetails { get; } diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index a09489d2d..293b06fdf 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -606,15 +606,15 @@ public static ConversationStatusDetails ConversationStatusDetails(ConversationSt return new ConversationStatusDetails(statusKind, incompleteReason, error, additionalBinaryDataProperties: null); } - public static ConversationTokenUsage ConversationTokenUsage(int? totalTokens = default, int? inputTokens = default, int? outputTokens = default, ConversationInputTokenUsageDetails inputTokenDetails = default, ConversationOutputTokenUsageDetails outputTokenDetails = default) + public static ConversationTokenUsage ConversationTokenUsage(int? totalTokens = default, ConversationInputTokenUsageDetails inputTokenDetails = default, ConversationOutputTokenUsageDetails outputTokenDetails = default, int inputTokenCount = default, int outputTokenCount = default) { return new ConversationTokenUsage( totalTokens, - inputTokens, - outputTokens, inputTokenDetails, outputTokenDetails, + inputTokenCount, + outputTokenCount, additionalBinaryDataProperties: null); } From 3cdf1bd30d575268b0282e9f3de7f5790aadcd35 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 22 Jan 2025 11:13:47 -0800 Subject: [PATCH 19/44] remove duplicated file after merge --- .../Chat/Example10_ChatWithAudioAsync.cs | 64 ------------------- 1 file changed, 64 deletions(-) delete mode 100644 .dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs diff --git a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs b/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs deleted file mode 100644 index fe6f2cf67..000000000 --- a/.dotnet/examples/Chat/Example10_ChatWithAudioAsync.cs +++ /dev/null @@ -1,64 +0,0 @@ -using NUnit.Framework; -using OpenAI.Chat; -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; - -namespace OpenAI.Examples; - -public partial class ChatExamples -{ - [Test] - public async Task Example10_ChatWithAudioAsync() - { - // Chat audio input and output is only supported on specific models, beginning with gpt-4o-audio-preview - ChatClient client = new("gpt-4o-audio-preview", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); - - // Input audio is provided to a request by adding an audio content part to a user message - string audioFilePath = Path.Combine("Assets", "realtime_whats_the_weather_pcm16_24khz_mono.wav"); - byte[] audioFileRawBytes = await File.ReadAllBytesAsync(audioFilePath); - BinaryData audioData = BinaryData.FromBytes(audioFileRawBytes); - List messages = - [ - new UserChatMessage(ChatMessageContentPart.CreateInputAudioPart(audioData, ChatInputAudioFormat.Wav)), - ]; - - // Output audio is requested by configuring ChatCompletionOptions to include the appropriate - // ResponseModalities values and corresponding AudioOptions. - ChatCompletionOptions options = new() - { - ResponseModalities = ChatResponseModalities.Text | ChatResponseModalities.Audio, - AudioOptions = new(ChatOutputAudioVoice.Alloy, ChatOutputAudioFormat.Mp3), - }; - - ChatCompletion completion = await client.CompleteChatAsync(messages, options); - - async Task PrintAudioContentAsync() - { - if (completion.OutputAudio is ChatOutputAudio outputAudio) - { - Console.WriteLine($"Response audio transcript: {outputAudio.Transcript}"); - string outputFilePath = $"{outputAudio.Id}.mp3"; - using (FileStream outputFileStream = File.OpenWrite(outputFilePath)) - { - await outputFileStream.WriteAsync(outputAudio.AudioBytes); - } - Console.WriteLine($"Response audio written to file: {outputFilePath}"); - Console.WriteLine($"Valid on followup requests until: {outputAudio.ExpiresAt}"); - } - } - - await PrintAudioContentAsync(); - - // To refer to past audio output, create an assistant message from the earlier ChatCompletion, use the earlier - // response content part, or use ChatMessageContentPart.CreateAudioPart(string) to manually instantiate a part. - - messages.Add(new AssistantChatMessage(completion)); - messages.Add("Can you say that like a pirate?"); - - completion = await client.CompleteChatAsync(messages, options); - - await PrintAudioContentAsync(); - } -} From 95d86974655afc8936c8df06ab608ebcd6c5632a Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 22 Jan 2025 13:00:13 -0800 Subject: [PATCH 20/44] tool updates for new spec peculiarities --- .openapi3/openapi3-openai.yaml | 44 +- .typespec/chat/models.tsp | 26 +- .typespec/completions/models.tsp | 2 - .typespec/realtime/models.tsp | 18 +- .typespec/runs/models.tsp | 1 - .typespec/threads/models.tsp | 4 + .typespec/uploads/models.tsp | 5 +- README.md | 12 +- openapi3-original.yaml | 950 +++++++++++++++++++------------ 9 files changed, 624 insertions(+), 438 deletions(-) diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index c9d98296b..730716937 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -5108,8 +5108,6 @@ components: type: integer format: int64 nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 description: |- This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. @@ -5122,12 +5120,10 @@ components: nullable: true description: |- Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. + - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. + - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + - When not set, the default behavior is 'auto'. default: auto stop: anyOf: @@ -5299,7 +5295,7 @@ components: - scale - default nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + description: The service tier used for processing the request. system_fingerprint: type: string description: |- @@ -5393,7 +5389,7 @@ components: - scale - default nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + description: The service tier used for processing the request. system_fingerprint: type: string description: |- @@ -5556,8 +5552,6 @@ components: type: integer format: int64 nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 description: |- If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. @@ -6730,9 +6724,7 @@ components: type: string description: The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. thread: - allOf: - - $ref: '#/components/schemas/CreateThreadRequest' - description: If no thread is provided, an empty thread will be created. + $ref: '#/components/schemas/CreateThreadRequest' model: anyOf: - type: string @@ -6887,6 +6879,9 @@ components: nullable: true description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. x-oaiTypeLabel: map + description: |- + Options to create a new thread. If no thread is provided when running a + request, an empty thread will be created. CreateThreadRequestToolResourcesFileSearchBase: type: object CreateThreadRequestToolResourcesFileSearchVectorStoreCreationHelpers: @@ -9753,10 +9748,11 @@ components: previous_item_id: type: string description: |- - The ID of the preceding item after which the new item will be inserted. + The ID of the preceding item after which the new item will be inserted. If not set, the new item will be appended to the end of the conversation. - If set, it allows an item to be inserted mid-conversation. If the ID - cannot be found, an error will be returned and the item will not be added. + If set to `root`, the new item will be added to the beginning of the conversation. + If set to an existing ID, it allows an item to be inserted mid-conversation. If the + ID cannot be found, an error will be returned and the item will not be added. item: $ref: '#/components/schemas/RealtimeConversationRequestItem' allOf: @@ -11657,8 +11653,6 @@ components: description: Realtime session object configuration. RealtimeSessionCreateRequest: type: object - required: - - model properties: modalities: type: array @@ -11702,11 +11696,16 @@ components: input_audio_format: allOf: - $ref: '#/components/schemas/RealtimeAudioFormat' - description: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + description: |- + The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + For `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, + single channel (mono), and little-endian byte order. output_audio_format: allOf: - $ref: '#/components/schemas/RealtimeAudioFormat' - description: The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + description: |- + The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + For `pcm16`, output audio is sampled at a rate of 24kHz. input_audio_transcription: type: object properties: @@ -13372,7 +13371,6 @@ components: allOf: - $ref: '#/components/schemas/OpenAIFile' nullable: true - description: The ready File object after the Upload is completed. description: The Upload object can accept byte chunks in the form of Parts. UploadPart: type: object diff --git a/.typespec/chat/models.tsp b/.typespec/chat/models.tsp index 57b0e6296..d28f4413a 100644 --- a/.typespec/chat/models.tsp +++ b/.typespec/chat/models.tsp @@ -222,19 +222,15 @@ model CreateChatCompletionRequest { If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. """) - @minValue(-9223372036854776000) - @maxValue(9223372036854776000) seed?: int64 | null; - @doc(""" - Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. - """) + /** + * Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: + * - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. + * - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + * - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + * - When not set, the default behavior is 'auto'. + */ service_tier?: "auto" | "default" | null = "auto"; /** Up to 4 sequences where the API will stop generating further tokens. */ @@ -356,9 +352,7 @@ model CreateChatCompletionResponse { /** The model used for the chat completion. */ `model`: string; - @doc(""" - The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - """) + /** The service tier used for processing the request. */ service_tier?: "scale" | "default" | null; @doc(""" @@ -920,9 +914,7 @@ model CreateChatCompletionStreamResponse { /** The model to generate the completion. */ `model`: string; - @doc(""" - The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - """) + /** The service tier used for processing the request. */ service_tier?: "scale" | "default" | null; @doc(""" diff --git a/.typespec/completions/models.tsp b/.typespec/completions/models.tsp index 8417de0c2..4ac388561 100644 --- a/.typespec/completions/models.tsp +++ b/.typespec/completions/models.tsp @@ -94,8 +94,6 @@ model CreateCompletionRequest { Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. """) - @minValue(-9223372036854776000) - @maxValue(9223372036854776000) seed?: int64 | null; /** Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. */ diff --git a/.typespec/realtime/models.tsp b/.typespec/realtime/models.tsp index 7c7b4a8e4..f2d9c742e 100644 --- a/.typespec/realtime/models.tsp +++ b/.typespec/realtime/models.tsp @@ -224,12 +224,13 @@ model RealtimeClientEventConversationItemCreate extends RealtimeClientEvent { """) type: RealtimeClientEventType.conversation_item_create; - /** - * The ID of the preceding item after which the new item will be inserted. - * If not set, the new item will be appended to the end of the conversation. - * If set, it allows an item to be inserted mid-conversation. If the ID - * cannot be found, an error will be returned and the item will not be added. - */ + @doc(""" + The ID of the preceding item after which the new item will be inserted. + If not set, the new item will be appended to the end of the conversation. + If set to `root`, the new item will be added to the beginning of the conversation. + If set to an existing ID, it allows an item to be inserted mid-conversation. If the + ID cannot be found, an error will be returned and the item will not be added. + """) previous_item_id?: string; // Tool customization: apply enriched item definition hierarchy @@ -1128,7 +1129,7 @@ model RealtimeSessionCreateRequest { modalities?: RealtimeModality[]; /** The Realtime model used for this session. */ - `model`: + `model`?: | "gpt-4o-realtime-preview" | "gpt-4o-realtime-preview-2024-10-01" | "gpt-4o-realtime-preview-2024-12-17" @@ -1163,12 +1164,15 @@ model RealtimeSessionCreateRequest { // Tool customization: use extracted and reusable audio format definition @doc(""" The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + For `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, + single channel (mono), and little-endian byte order. """) input_audio_format?: RealtimeAudioFormat; // Tool customization: use extracted and reusable audio format definition @doc(""" The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + For `pcm16`, output audio is sampled at a rate of 24kHz. """) output_audio_format?: RealtimeAudioFormat; diff --git a/.typespec/runs/models.tsp b/.typespec/runs/models.tsp index c19fa6f67..4e23d851c 100644 --- a/.typespec/runs/models.tsp +++ b/.typespec/runs/models.tsp @@ -125,7 +125,6 @@ model CreateThreadAndRunRequest { /** The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. */ assistant_id: string; - /** If no thread is provided, an empty thread will be created. */ thread?: CreateThreadRequest; /** The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. */ diff --git a/.typespec/threads/models.tsp b/.typespec/threads/models.tsp index 5dd856582..8be177906 100644 --- a/.typespec/threads/models.tsp +++ b/.typespec/threads/models.tsp @@ -10,6 +10,10 @@ using TypeSpec.OpenAPI; namespace OpenAI; +/** + * Options to create a new thread. If no thread is provided when running a + * request, an empty thread will be created. + */ model CreateThreadRequest { /** A list of [messages](/docs/api-reference/messages) to start the thread with. */ messages?: CreateMessageRequest[]; diff --git a/.typespec/uploads/models.tsp b/.typespec/uploads/models.tsp index 1754186de..539d13eb3 100644 --- a/.typespec/uploads/models.tsp +++ b/.typespec/uploads/models.tsp @@ -17,7 +17,7 @@ model AdminApiKey { value?: string; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime - @encode("unixTimestamp", int32) + @encode("unixTimestamp", int64) created_at?: utcDateTime; owner?: { @@ -26,7 +26,7 @@ model AdminApiKey { name?: string; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime - @encode("unixTimestamp", int32) + @encode("unixTimestamp", int64) created_at?: utcDateTime; role?: string; @@ -100,7 +100,6 @@ model Upload { /** The object type, which is always "upload". */ object?: "upload"; - /** The ready File object after the Upload is completed. */ file?: OpenAIFile | null; } diff --git a/README.md b/README.md index 88b4057de..f913b25b8 100644 --- a/README.md +++ b/README.md @@ -3,18 +3,18 @@ For information on spec ingestion, see the Sorento wiki page: https://dev.azure.com/project-argos/Sorento/_wiki/wikis/Sorento.wiki/3021/Generate-OpenAI's-YAML-Spec -Snapshot: https://project-argos@dev.azure.com/project-argos/Sorento/_git/export-api +Snapshot: $M ``` -commit 41af04dc4767cfd11ca4fbc7edf2e5a67a564440 (HEAD -> main, origin/main) -Author: Git-Mirror-Tool Synchronizer -Date: Mon Jan 13 22:49:02 2025 +0000 +commit 9ca412840f1554cc23857a6a2aa1e66c231a8b40 (HEAD -> master, origin/master) +Author: root +Date: Wed Jan 22 19:03:08 2025 +0000 ``` Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk ``` -commit c41442a13bf38ac4f30840bee648488991661e17 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) +commit 7ec86ce9fbb544f7542979b601aaaec8c37263f6 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) Author: Travis Wilson -Date: Thu Jan 9 14:24:11 2025 -0800 +Date: Wed Jan 22 12:43:20 2025 -0800 ``` There are some deltas: diff --git a/openapi3-original.yaml b/openapi3-original.yaml index 788092a28..1a259698a 100644 --- a/openapi3-original.yaml +++ b/openapi3-original.yaml @@ -1364,6 +1364,9 @@ paths: application/json: schema: $ref: "#/components/schemas/CreateChatCompletionResponse" + text/event-stream: + schema: + $ref: "#/components/schemas/CreateChatCompletionStreamResponse" x-oaiMeta: name: Create chat completion group: chat @@ -1420,6 +1423,7 @@ paths: const completion = await openai.chat.completions.create({ messages: [{ role: "developer", content: "You are a helpful assistant." }], model: "VAR_chat_model_id", + store: true, }); console.log(completion.choices[0]); @@ -1443,6 +1447,7 @@ paths: "logprobs": null, "finish_reason": "stop" }], + "service_tier": "default", "usage": { "prompt_tokens": 9, "completion_tokens": 12, @@ -1533,6 +1538,7 @@ paths: ], }, ], + store: true, }); console.log(response.choices[0]); } @@ -1617,6 +1623,7 @@ paths: {"role": "developer", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], + store: true, stream: true, }); @@ -1751,6 +1758,7 @@ paths: messages: messages, tools: tools, tool_choice: "auto", + store: true, }); console.log(response); @@ -1837,6 +1845,7 @@ paths: const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: "Hello!" }], model: "VAR_chat_model_id", + store: true, logprobs: true, top_logprobs: 2, }); @@ -4001,11 +4010,6 @@ paths: application/json: schema: $ref: "#/components/schemas/ApiKeyList" - security: - - bearer_identity_edge: - - key.secret - - api.management.read - - basic_identity_edge: [] x-oaiMeta: name: List admin API keys group: administration @@ -4063,11 +4067,6 @@ paths: application/json: schema: $ref: "#/components/schemas/AdminApiKey" - security: - - bearer_identity_edge: - - key.secret - - api.management.write - - basic_identity_edge: [] x-oaiMeta: name: Create admin API key group: administration @@ -4118,11 +4117,6 @@ paths: application/json: schema: $ref: "#/components/schemas/AdminApiKey" - security: - - bearer_identity_edge: - - key.secret - - api.management.read - - basic_identity_edge: [] x-oaiMeta: name: Retrieve admin API key group: administration @@ -4178,11 +4172,6 @@ paths: deleted: type: boolean example: true - security: - - bearer_identity_edge: - - key.secret - - api.management.write - - basic_identity_edge: [] x-oaiMeta: name: Delete admin API key group: administration @@ -4645,18 +4634,17 @@ paths: curl https://api.openai.com/v1/organization/invites/invite-abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.invite", - "id": "invite-abc", - "email": "user@example.com", - "role": "owner", - "status": "accepted", - "invited_at": 1711471533, - "expires_at": 1711471533, - "accepted_at": 1711471533 - } + response: | + { + "object": "organization.invite", + "id": "invite-abc", + "email": "user@example.com", + "role": "owner", + "status": "accepted", + "invited_at": 1711471533, + "expires_at": 1711471533, + "accepted_at": 1711471533 + } delete: summary: Delete an invite. If the invite has already been accepted, it cannot be deleted. @@ -4688,13 +4676,12 @@ paths: https://api.openai.com/v1/organization/invites/invite-abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.invite.deleted", - "id": "invite-abc", - "deleted": true - } + response: | + { + "object": "organization.invite.deleted", + "id": "invite-abc", + "deleted": true + } /organization/projects: get: summary: Returns a list of projects. @@ -4745,24 +4732,23 @@ paths: curl https://api.openai.com/v1/organization/projects?after=proj_abc&limit=20&include_archived=false \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "id": "proj_abc", - "object": "organization.project", - "name": "Project example", - "created_at": 1711471533, - "archived_at": null, - "status": "active" - } - ], - "first_id": "proj-abc", - "last_id": "proj-xyz", - "has_more": false - } + response: | + { + "object": "list", + "data": [ + { + "id": "proj_abc", + "object": "organization.project", + "name": "Project example", + "created_at": 1711471533, + "archived_at": null, + "status": "active" + } + ], + "first_id": "proj-abc", + "last_id": "proj-xyz", + "has_more": false + } post: summary: Create a new project in the organization. Projects can be created and archived, but cannot be deleted. @@ -4796,16 +4782,15 @@ paths: -d '{ "name": "Project ABC" }' - response: - content: | - { - "id": "proj_abc", - "object": "organization.project", - "name": "Project ABC", - "created_at": 1711471533, - "archived_at": null, - "status": "active" - } + response: | + { + "id": "proj_abc", + "object": "organization.project", + "name": "Project ABC", + "created_at": 1711471533, + "archived_at": null, + "status": "active" + } /organization/projects/{project_id}: get: summary: Retrieves a project. @@ -4838,16 +4823,15 @@ paths: curl https://api.openai.com/v1/organization/projects/proj_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "id": "proj_abc", - "object": "organization.project", - "name": "Project example", - "created_at": 1711471533, - "archived_at": null, - "status": "active" - } + response: | + { + "id": "proj_abc", + "object": "organization.project", + "name": "Project example", + "created_at": 1711471533, + "archived_at": null, + "status": "active" + } post: summary: Modifies a project in the organization. operationId: modify-project @@ -4944,40 +4928,33 @@ paths: curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys?after=key_abc&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.project.api_key", - "redacted_value": "sk-abc...def", - "name": "My API Key", - "created_at": 1711471533, - "id": "key_abc", - "owner": { - "type": "user", - "user": { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - } - } - ], - "first_id": "key_abc", - "last_id": "key_xyz", - "has_more": false - } - error_response: - content: | - { - "code": 400, - "message": "Project {name} is archived" - } + response: | + { + "object": "list", + "data": [ + { + "object": "organization.project.api_key", + "redacted_value": "sk-abc...def", + "name": "My API Key", + "created_at": 1711471533, + "id": "key_abc", + "owner": { + "type": "user", + "user": { + "object": "organization.project.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + } + } + ], + "first_id": "key_abc", + "last_id": "key_xyz", + "has_more": false + } /organization/projects/{project_id}/api_keys/{key_id}: get: summary: Retrieves an API key in the project. @@ -5015,26 +4992,25 @@ paths: curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.api_key", - "redacted_value": "sk-abc...def", - "name": "My API Key", - "created_at": 1711471533, - "id": "key_abc", - "owner": { - "type": "user", - "user": { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - } - } + response: | + { + "object": "organization.project.api_key", + "redacted_value": "sk-abc...def", + "name": "My API Key", + "created_at": 1711471533, + "id": "key_abc", + "owner": { + "type": "user", + "user": { + "object": "organization.project.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + } + } delete: summary: Deletes an API key from the project. operationId: delete-project-api-key @@ -5077,19 +5053,12 @@ paths: curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.api_key.deleted", - "id": "key_abc", - "deleted": true - } - error_response: - content: > - { - "code": 400, - "message": "API keys cannot be deleted for service accounts, please delete the service account" - } + response: | + { + "object": "organization.project.api_key.deleted", + "id": "key_abc", + "deleted": true + } /organization/projects/{project_id}/archive: post: summary: Archives a project in the organization. Archived projects cannot be @@ -5122,16 +5091,15 @@ paths: https://api.openai.com/v1/organization/projects/proj_abc/archive \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "id": "proj_abc", - "object": "organization.project", - "name": "Project DEF", - "created_at": 1711471533, - "archived_at": 1711471533, - "status": "archived" - } + response: | + { + "id": "proj_abc", + "object": "organization.project", + "name": "Project DEF", + "created_at": 1711471533, + "archived_at": 1711471533, + "status": "archived" + } /organization/projects/{project_id}/rate_limits: get: summary: Returns the rate limits per model for a project. @@ -5340,23 +5308,22 @@ paths: curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts?after=custom_id&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.project.service_account", - "id": "svc_acct_abc", - "name": "Service Account", - "role": "owner", - "created_at": 1711471533 - } - ], - "first_id": "svc_acct_abc", - "last_id": "svc_acct_xyz", - "has_more": false - } + response: | + { + "object": "list", + "data": [ + { + "object": "organization.project.service_account", + "id": "svc_acct_abc", + "name": "Service Account", + "role": "owner", + "created_at": 1711471533 + } + ], + "first_id": "svc_acct_abc", + "last_id": "svc_acct_xyz", + "has_more": false + } post: summary: Creates a new service account in the project. This also returns an unredacted API key for the service account. @@ -5405,22 +5372,21 @@ paths: -d '{ "name": "Production App" }' - response: - content: | - { - "object": "organization.project.service_account", - "id": "svc_acct_abc", - "name": "Production App", - "role": "member", - "created_at": 1711471533, - "api_key": { - "object": "organization.project.service_account.api_key", - "value": "sk-abcdefghijklmnop123", - "name": "Secret Key", - "created_at": 1711471533, - "id": "key_abc" - } - } + response: | + { + "object": "organization.project.service_account", + "id": "svc_acct_abc", + "name": "Production App", + "role": "member", + "created_at": 1711471533, + "api_key": { + "object": "organization.project.service_account.api_key", + "value": "sk-abcdefghijklmnop123", + "name": "Secret Key", + "created_at": 1711471533, + "id": "key_abc" + } + } /organization/projects/{project_id}/service_accounts/{service_account_id}: get: summary: Retrieves a service account in the project. @@ -5459,15 +5425,14 @@ paths: curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.service_account", - "id": "svc_acct_abc", - "name": "Service Account", - "role": "owner", - "created_at": 1711471533 - } + response: | + { + "object": "organization.project.service_account", + "id": "svc_acct_abc", + "name": "Service Account", + "role": "owner", + "created_at": 1711471533 + } delete: summary: Deletes a service account from the project. operationId: delete-project-service-account @@ -5504,13 +5469,12 @@ paths: curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.service_account.deleted", - "id": "svc_acct_abc", - "deleted": true - } + response: | + { + "object": "organization.project.service_account.deleted", + "id": "svc_acct_abc", + "deleted": true + } /organization/projects/{project_id}/users: get: summary: Returns a list of users in the project. @@ -5567,30 +5531,23 @@ paths: curl https://api.openai.com/v1/organization/projects/proj_abc/users?after=user_abc&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - ], - "first_id": "user-abc", - "last_id": "user-xyz", - "has_more": false - } - error_response: - content: | - { - "code": 400, - "message": "Project {name} is archived" - } + response: | + { + "object": "list", + "data": [ + { + "object": "organization.project.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + ], + "first_id": "user-abc", + "last_id": "user-xyz", + "has_more": false + } post: summary: Adds a user to the project. Users must already be members of the organization to be added to a project. @@ -5640,21 +5597,14 @@ paths: "user_id": "user_abc", "role": "member" }' - response: - content: | - { - "object": "organization.project.user", - "id": "user_abc", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - error_response: - content: | - { - "code": 400, - "message": "Project {name} is archived" - } + response: | + { + "object": "organization.project.user", + "id": "user_abc", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } /organization/projects/{project_id}/users/{user_id}: get: summary: Retrieves a user in the project. @@ -5692,16 +5642,15 @@ paths: curl https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } + response: | + { + "object": "organization.project.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } post: summary: Modifies a user's role in the project. operationId: modify-project-user @@ -5754,16 +5703,15 @@ paths: -d '{ "role": "owner" }' - response: - content: | - { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } + response: | + { + "object": "organization.project.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } delete: summary: Deletes a user from the project. operationId: delete-project-user @@ -5806,13 +5754,12 @@ paths: curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.user.deleted", - "id": "user_abc", - "deleted": true - } + response: | + { + "object": "organization.project.user.deleted", + "id": "user_abc", + "deleted": true + } /organization/usage/audio_speeches: get: summary: Get audio speeches usage details for the organization. @@ -6929,24 +6876,23 @@ paths: curl https://api.openai.com/v1/organization/users?after=user_abc&limit=20 \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - ], - "first_id": "user-abc", - "last_id": "user-xyz", - "has_more": false - } + response: | + { + "object": "list", + "data": [ + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + ], + "first_id": "user-abc", + "last_id": "user-xyz", + "has_more": false + } /organization/users/{user_id}: get: summary: Retrieves a user by their identifier. @@ -6978,16 +6924,15 @@ paths: curl https://api.openai.com/v1/organization/users/user_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } + response: | + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } post: summary: Modifies a user's role in the organization. operationId: modify-user @@ -7028,16 +6973,15 @@ paths: -d '{ "role": "owner" }' - response: - content: | - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } + response: | + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } delete: summary: Deletes a user from the organization. operationId: delete-user @@ -7068,13 +7012,12 @@ paths: https://api.openai.com/v1/organization/users/user_abc \ -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.user.deleted", - "id": "user_abc", - "deleted": true - } + response: | + { + "object": "organization.user.deleted", + "id": "user_abc", + "deleted": true + } /realtime/sessions: post: summary: > @@ -11004,7 +10947,7 @@ paths: "object": "vector_store.file_batch", "created_at": 1699061776, "vector_store_id": "vs_abc123", - "status": "cancelling", + "status": "in_progress", "file_counts": { "in_progress": 12, "completed": 3, @@ -11238,6 +11181,7 @@ components: type: string enum: - assistant + x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the assistant was created. type: integer @@ -11353,8 +11297,9 @@ components: We generally recommend altering this or temperature but not both. response_format: - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" - nullable: true + allOf: + - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" + - nullable: true required: - id - object @@ -11419,6 +11364,7 @@ components: `auto` is the default value enum: - auto + x-stainless-const: true - $ref: "#/components/schemas/ResponseFormatText" - $ref: "#/components/schemas/ResponseFormatJsonObject" - $ref: "#/components/schemas/ResponseFormatJsonSchema" @@ -11537,6 +11483,7 @@ components: description: "The type of tool being defined: `code_interpreter`" enum: - code_interpreter + x-stainless-const: true required: - type AssistantToolsFileSearch: @@ -11548,6 +11495,7 @@ components: description: "The type of tool being defined: `file_search`" enum: - file_search + x-stainless-const: true file_search: type: object description: Overrides for the file search tool. @@ -11573,6 +11521,7 @@ components: description: "The type of tool being defined: `file_search`" enum: - file_search + x-stainless-const: true required: - type AssistantToolsFunction: @@ -11584,6 +11533,7 @@ components: description: "The type of tool being defined: `function`" enum: - function + x-stainless-const: true function: $ref: "#/components/schemas/FunctionObject" required: @@ -11938,10 +11888,8 @@ components: - session - api_key session: - type: object $ref: "#/components/schemas/AuditLogActorSession" api_key: - type: object $ref: "#/components/schemas/AuditLogActorApiKey" AuditLogActorApiKey: type: object @@ -12025,6 +11973,7 @@ components: description: Always `auto`. enum: - auto + x-stainless-const: true required: - type Batch: @@ -12037,6 +11986,7 @@ components: enum: - batch description: The object type, which is always `batch`. + x-stainless-const: true endpoint: type: string description: The OpenAI API endpoint used by the batch. @@ -12201,6 +12151,7 @@ components: - POST description: The HTTP method to be used for the request. Currently only `POST` is supported. + x-stainless-const: true url: type: string description: The OpenAI API relative URL to be used for the request. Currently @@ -12301,6 +12252,7 @@ components: enum: - function description: The type of the tool. Currently, only `function` is supported. + x-stainless-const: true function: type: object description: The function that the model called. @@ -12335,6 +12287,7 @@ components: enum: - function description: The type of the tool. Currently, only `function` is supported. + x-stainless-const: true function: type: object properties: @@ -12391,6 +12344,7 @@ components: enum: - function description: The type of the tool. Currently, only `function` is supported. + x-stainless-const: true function: type: object properties: @@ -12434,6 +12388,7 @@ components: enum: - assistant description: The role of the messages author, in this case `assistant`. + x-stainless-const: true name: type: string description: An optional name for the participant. Provides the model @@ -12511,6 +12466,7 @@ components: enum: - developer description: The role of the messages author, in this case `developer`. + x-stainless-const: true name: type: string description: An optional name for the participant. Provides the model @@ -12528,6 +12484,7 @@ components: enum: - function description: The role of the messages author, in this case `function`. + x-stainless-const: true content: nullable: true type: string @@ -12559,6 +12516,7 @@ components: enum: - input_audio description: The type of the content part. Always `input_audio`. + x-stainless-const: true input_audio: type: object properties: @@ -12590,6 +12548,7 @@ components: enum: - image_url description: The type of the content part. + x-stainless-const: true image_url: type: object properties: @@ -12620,6 +12579,7 @@ components: enum: - refusal description: The type of the content part. + x-stainless-const: true refusal: type: string description: The refusal message generated by the model. @@ -12637,6 +12597,7 @@ components: enum: - text description: The type of the content part. + x-stainless-const: true text: type: string description: The text content. @@ -12673,6 +12634,7 @@ components: enum: - system description: The role of the messages author, in this case `system`. + x-stainless-const: true name: type: string description: An optional name for the participant. Provides the model @@ -12693,6 +12655,7 @@ components: enum: - tool description: The role of the messages author, in this case `tool`. + x-stainless-const: true content: oneOf: - type: string @@ -12745,6 +12708,7 @@ components: enum: - user description: The role of the messages author, in this case `user`. + x-stainless-const: true name: type: string description: An optional name for the participant. Provides the model @@ -12777,6 +12741,7 @@ components: enum: - assistant description: The role of the author of this message. + x-stainless-const: true function_call: type: object deprecated: true @@ -12949,6 +12914,7 @@ components: enum: - function description: The type of the tool. Currently, only `function` is supported. + x-stainless-const: true function: $ref: "#/components/schemas/FunctionObject" required: @@ -13073,6 +13039,7 @@ components: type: string enum: - organization.costs.result + x-stainless-const: true amount: type: object description: The monetary value in its associated currency. @@ -13095,7 +13062,6 @@ components: the grouped costs result. required: - object - - sessions x-oaiMeta: name: Costs object example: | @@ -13252,6 +13218,7 @@ components: description: Always `auto`. enum: - auto + x-stainless-const: true required: - type - type: object @@ -13263,6 +13230,7 @@ components: description: Always `static`. enum: - static + x-stainless-const: true static: type: object additionalProperties: false @@ -13342,8 +13310,9 @@ components: We generally recommend altering this or temperature but not both. response_format: - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" - nullable: true + allOf: + - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" + - nullable: true required: - model CreateChatCompletionFunctionResponse: @@ -13364,7 +13333,6 @@ components: - finish_reason - index - message - - logprobs properties: finish_reason: type: string @@ -13407,6 +13375,7 @@ components: description: The object type, which is always `chat.completion`. enum: - chat.completion + x-stainless-const: true usage: $ref: "#/components/schemas/CompletionUsage" required: @@ -13815,8 +13784,7 @@ components: x-oaiExpandable: true seed: type: integer - minimum: -9223372036854776000 - maximum: 9223372036854776000 + format: int64 nullable: true description: > This feature is in Beta. @@ -13839,8 +13807,6 @@ components: - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. type: string enum: - auto @@ -14051,9 +14017,7 @@ components: type: string description: The model used for the chat completion. service_tier: - description: The service tier used for processing the request. This field is - only included if the `service_tier` parameter is specified in the - request. + description: The service tier used for processing the request. type: string enum: - scale @@ -14075,6 +14039,7 @@ components: description: The object type, which is always `chat.completion`. enum: - chat.completion + x-stainless-const: true usage: $ref: "#/components/schemas/CompletionUsage" required: @@ -14197,9 +14162,7 @@ components: type: string description: The model to generate the completion. service_tier: - description: The service tier used for processing the request. This field is - only included if the `service_tier` parameter is specified in the - request. + description: The service tier used for processing the request. type: string enum: - scale @@ -14220,6 +14183,7 @@ components: description: The object type, which is always `chat.completion.chunk`. enum: - chat.completion.chunk + x-stainless-const: true usage: type: object nullable: true @@ -14429,8 +14393,7 @@ components: penalties.](/docs/guides/text-generation) seed: type: integer - minimum: -9223372036854776000 - maximum: 9223372036854776000 + format: int64 nullable: true description: > If specified, our system will make a best effort to sample @@ -14599,6 +14562,7 @@ components: description: The object type, which is always "text_completion" enum: - text_completion + x-stainless-const: true usage: $ref: "#/components/schemas/CompletionUsage" required: @@ -14730,6 +14694,7 @@ components: description: The object type, which is always "list". enum: - list + x-stainless-const: true usage: type: object description: The usage information for the request. @@ -14838,6 +14803,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: integer minimum: 1 maximum: 256 @@ -14852,6 +14818,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: number minimum: 0 exclusiveMinimum: true @@ -14866,6 +14833,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: integer minimum: 1 maximum: 50 @@ -14927,6 +14895,7 @@ components: - type: string enum: - wandb + x-stainless-const: true wandb: type: object description: > @@ -15016,6 +14985,7 @@ components: - type: string enum: - dall-e-2 + x-stainless-const: true x-oaiTypeLabel: string default: dall-e-2 example: dall-e-2 @@ -15162,6 +15132,7 @@ components: - type: string enum: - dall-e-2 + x-stainless-const: true x-oaiTypeLabel: string default: dall-e-2 example: dall-e-2 @@ -15313,6 +15284,7 @@ components: type: string enum: - image_url + x-stainless-const: true image_url: type: object description: Contains either an image URL or a data URL for a base64 encoded @@ -15336,6 +15308,7 @@ components: type: string enum: - text + x-stainless-const: true text: description: A string of text to classify. type: string @@ -15533,6 +15506,7 @@ components: type: string enum: - text + x-stainless-const: true hate/threatening: type: array description: The applied input type(s) for the category 'hate/threatening'. @@ -15540,6 +15514,7 @@ components: type: string enum: - text + x-stainless-const: true harassment: type: array description: The applied input type(s) for the category 'harassment'. @@ -15547,6 +15522,7 @@ components: type: string enum: - text + x-stainless-const: true harassment/threatening: type: array description: The applied input type(s) for the category @@ -15555,6 +15531,7 @@ components: type: string enum: - text + x-stainless-const: true illicit: type: array description: The applied input type(s) for the category 'illicit'. @@ -15562,6 +15539,7 @@ components: type: string enum: - text + x-stainless-const: true illicit/violent: type: array description: The applied input type(s) for the category 'illicit/violent'. @@ -15569,6 +15547,7 @@ components: type: string enum: - text + x-stainless-const: true self-harm: type: array description: The applied input type(s) for the category 'self-harm'. @@ -15609,6 +15588,7 @@ components: type: string enum: - text + x-stainless-const: true violence: type: array description: The applied input type(s) for the category 'violence'. @@ -15876,16 +15856,19 @@ components: for more info. minimum: 256 truncation_strategy: - $ref: "#/components/schemas/TruncationObject" - nullable: true + allOf: + - $ref: "#/components/schemas/TruncationObject" + - nullable: true tool_choice: - $ref: "#/components/schemas/AssistantsApiToolChoiceOption" - nullable: true + allOf: + - $ref: "#/components/schemas/AssistantsApiToolChoiceOption" + - nullable: true parallel_tool_calls: $ref: "#/components/schemas/ParallelToolCalls" response_format: - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" - nullable: true + allOf: + - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" + - nullable: true required: - assistant_id CreateSpeechRequest: @@ -15957,7 +15940,6 @@ components: type: string thread: $ref: "#/components/schemas/CreateThreadRequest" - description: If no thread is provided, an empty thread will be created. model: description: The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the @@ -16109,20 +16091,26 @@ components: for more info. minimum: 256 truncation_strategy: - $ref: "#/components/schemas/TruncationObject" - nullable: true + allOf: + - $ref: "#/components/schemas/TruncationObject" + - nullable: true tool_choice: - $ref: "#/components/schemas/AssistantsApiToolChoiceOption" - nullable: true + allOf: + - $ref: "#/components/schemas/AssistantsApiToolChoiceOption" + - nullable: true parallel_tool_calls: $ref: "#/components/schemas/ParallelToolCalls" response_format: - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" - nullable: true + allOf: + - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" + - nullable: true required: - assistant_id CreateThreadRequest: type: object + description: | + Options to create a new thread. If no thread is provided when running a + request, an empty thread will be created. additionalProperties: false properties: messages: @@ -16201,6 +16189,7 @@ components: description: Always `auto`. enum: - auto + x-stainless-const: true required: - type - type: object @@ -16212,6 +16201,7 @@ components: description: Always `static`. enum: - static + x-stainless-const: true static: type: object additionalProperties: false @@ -16286,6 +16276,7 @@ components: - type: string enum: - whisper-1 + x-stainless-const: true x-oaiTypeLabel: string language: description: > @@ -16423,6 +16414,7 @@ components: - type: string enum: - whisper-1 + x-stainless-const: true x-oaiTypeLabel: string prompt: description: > @@ -16595,6 +16587,7 @@ components: type: string enum: - assistant.deleted + x-stainless-const: true required: - id - object @@ -16608,6 +16601,7 @@ components: type: string enum: - file + x-stainless-const: true deleted: type: boolean required: @@ -16625,6 +16619,7 @@ components: type: string enum: - thread.message.deleted + x-stainless-const: true required: - id - object @@ -16653,6 +16648,7 @@ components: type: string enum: - thread.deleted + x-stainless-const: true required: - id - object @@ -16668,6 +16664,7 @@ components: type: string enum: - vector_store.file.deleted + x-stainless-const: true required: - id - object @@ -16683,6 +16680,7 @@ components: type: string enum: - vector_store.deleted + x-stainless-const: true required: - id - object @@ -16694,10 +16692,12 @@ components: type: string enum: - done + x-stainless-const: true data: type: string enum: - "[DONE]" + x-stainless-const: true required: - event - data @@ -16725,6 +16725,7 @@ components: description: The object type, which is always "embedding". enum: - embedding + x-stainless-const: true required: - index - object @@ -16769,6 +16770,7 @@ components: type: string enum: - error + x-stainless-const: true data: $ref: "#/components/schemas/Error" required: @@ -16931,6 +16933,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: number minimum: 0 maximum: 2 @@ -16945,6 +16948,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: integer minimum: 1 maximum: 256 @@ -16957,6 +16961,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: number minimum: 0 exclusiveMinimum: true @@ -16969,6 +16974,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: integer minimum: 1 maximum: 50 @@ -16984,10 +16990,8 @@ components: - supervised - dpo supervised: - type: object $ref: "#/components/schemas/FineTuneSupervisedMethod" dpo: - type: object $ref: "#/components/schemas/FineTuneDPOMethod" FineTunePreferenceRequestInput: type: object @@ -17070,6 +17074,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: integer minimum: 1 maximum: 256 @@ -17082,6 +17087,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: number minimum: 0 exclusiveMinimum: true @@ -17094,6 +17100,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: integer minimum: 1 maximum: 50 @@ -17110,6 +17117,7 @@ components: description: The type of the integration being enabled for the fine-tuning job enum: - wandb + x-stainless-const: true wandb: type: object description: > @@ -17217,6 +17225,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: integer minimum: 1 maximum: 256 @@ -17231,6 +17240,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: number minimum: 0 exclusiveMinimum: true @@ -17245,6 +17255,7 @@ components: - type: string enum: - auto + x-stainless-const: true - type: integer minimum: 1 maximum: 50 @@ -17257,6 +17268,7 @@ components: description: The object type, which is always "fine_tuning.job". enum: - fine_tuning.job + x-stainless-const: true organization_id: type: string description: The organization that owns the fine-tuning job. @@ -17415,6 +17427,7 @@ components: description: The object type, which is always "fine_tuning.job.checkpoint". enum: - fine_tuning.job.checkpoint + x-stainless-const: true required: - created_at - fine_tuning_job_id @@ -17452,6 +17465,7 @@ components: description: The object type, which is always "fine_tuning.job.event". enum: - fine_tuning.job.event + x-stainless-const: true id: type: string description: The object identifier. @@ -17577,6 +17591,7 @@ components: enum: - organization.invite description: The object type, which is always `organization.invite` + x-stainless-const: true id: type: string description: The identifier, which can be referenced in API endpoints @@ -17656,6 +17671,7 @@ components: enum: - organization.invite.deleted description: The object type, which is always `organization.invite.deleted` + x-stainless-const: true id: type: string deleted: @@ -17672,6 +17688,7 @@ components: enum: - list description: The object type, which is always `list` + x-stainless-const: true data: type: array items: @@ -17814,6 +17831,7 @@ components: type: string enum: - list + x-stainless-const: true data: type: array items: @@ -17851,6 +17869,7 @@ components: type: string enum: - list + x-stainless-const: true required: - object - data @@ -17891,6 +17910,7 @@ components: type: string enum: - list + x-stainless-const: true first_id: type: string nullable: true @@ -17914,6 +17934,7 @@ components: type: string enum: - list + x-stainless-const: true required: - object - data @@ -17948,6 +17969,7 @@ components: type: string enum: - list + x-stainless-const: true data: type: array items: @@ -17968,6 +17990,7 @@ components: type: string enum: - list + x-stainless-const: true required: - object - data @@ -18104,6 +18127,7 @@ components: type: string enum: - image_file + x-stainless-const: true image_file: type: object properties: @@ -18137,6 +18161,7 @@ components: enum: - image_url description: The type of the content part. + x-stainless-const: true image_url: type: object properties: @@ -18170,6 +18195,7 @@ components: type: string enum: - refusal + x-stainless-const: true refusal: type: string nullable: false @@ -18188,6 +18214,7 @@ components: type: string enum: - file_citation + x-stainless-const: true text: description: The text in the message content that needs to be replaced. type: string @@ -18222,6 +18249,7 @@ components: type: string enum: - file_path + x-stainless-const: true text: description: The text in the message content that needs to be replaced. type: string @@ -18255,6 +18283,7 @@ components: type: string enum: - text + x-stainless-const: true text: type: object properties: @@ -18288,6 +18317,7 @@ components: type: string enum: - image_file + x-stainless-const: true image_file: type: object properties: @@ -18322,6 +18352,7 @@ components: type: string enum: - image_url + x-stainless-const: true image_url: type: object properties: @@ -18354,6 +18385,7 @@ components: type: string enum: - refusal + x-stainless-const: true refusal: type: string required: @@ -18374,6 +18406,7 @@ components: type: string enum: - file_citation + x-stainless-const: true text: description: The text in the message content that needs to be replaced. type: string @@ -18409,6 +18442,7 @@ components: type: string enum: - file_path + x-stainless-const: true text: description: The text in the message content that needs to be replaced. type: string @@ -18440,6 +18474,7 @@ components: type: string enum: - text + x-stainless-const: true text: type: object properties: @@ -18473,6 +18508,7 @@ components: type: string enum: - thread.message.delta + x-stainless-const: true delta: description: The delta containing the fields that have changed on the Message. type: object @@ -18527,6 +18563,7 @@ components: type: string enum: - thread.message + x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the message was created. type: integer @@ -18673,6 +18710,7 @@ components: type: string enum: - text + x-stainless-const: true text: type: string description: Text content to be sent to the model @@ -18687,6 +18725,7 @@ components: type: string enum: - thread.message.created + x-stainless-const: true data: $ref: "#/components/schemas/MessageObject" required: @@ -18702,6 +18741,7 @@ components: type: string enum: - thread.message.in_progress + x-stainless-const: true data: $ref: "#/components/schemas/MessageObject" required: @@ -18717,6 +18757,7 @@ components: type: string enum: - thread.message.delta + x-stainless-const: true data: $ref: "#/components/schemas/MessageDeltaObject" required: @@ -18734,6 +18775,7 @@ components: type: string enum: - thread.message.completed + x-stainless-const: true data: $ref: "#/components/schemas/MessageObject" required: @@ -18749,6 +18791,7 @@ components: type: string enum: - thread.message.incomplete + x-stainless-const: true data: $ref: "#/components/schemas/MessageObject" required: @@ -18773,6 +18816,7 @@ components: description: The object type, which is always "model". enum: - model + x-stainless-const: true owned_by: type: string description: The organization that owns the model. @@ -18907,8 +18951,9 @@ components: We generally recommend altering this or temperature but not both. response_format: - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" - nullable: true + allOf: + - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" + - nullable: true ModifyMessageRequest: type: object additionalProperties: false @@ -19003,6 +19048,7 @@ components: description: The object type, which is always `file`. enum: - file + x-stainless-const: true purpose: type: string description: The intended purpose of the file. Supported values are @@ -19062,6 +19108,7 @@ components: description: Always `other`. enum: - other + x-stainless-const: true required: - type ParallelToolCalls: @@ -19089,6 +19136,7 @@ components: description: | The type of the predicted content you want to provide. This type is currently always `content`. + x-stainless-const: true content: x-oaiExpandable: true description: > @@ -19124,6 +19172,7 @@ components: enum: - organization.project description: The object type, which is always `organization.project` + x-stainless-const: true name: type: string description: The name of the project. This appears in reporting. @@ -19167,6 +19216,7 @@ components: enum: - organization.project.api_key description: The object type, which is always `organization.project.api_key` + x-stainless-const: true redacted_value: type: string description: The redacted value of the API key @@ -19227,6 +19277,7 @@ components: type: string enum: - organization.project.api_key.deleted + x-stainless-const: true id: type: string deleted: @@ -19242,6 +19293,7 @@ components: type: string enum: - list + x-stainless-const: true data: type: array items: @@ -19273,6 +19325,7 @@ components: type: string enum: - list + x-stainless-const: true data: type: array items: @@ -19298,6 +19351,7 @@ components: enum: - project.rate_limit description: The object type, which is always `project.rate_limit` + x-stainless-const: true id: type: string description: The identifier, which can be referenced in API endpoints. @@ -19348,6 +19402,7 @@ components: type: string enum: - list + x-stainless-const: true data: type: array items: @@ -19397,6 +19452,7 @@ components: - organization.project.service_account description: The object type, which is always `organization.project.service_account` + x-stainless-const: true id: type: string description: The identifier, which can be referenced in API endpoints @@ -19438,6 +19494,7 @@ components: - organization.project.service_account.api_key description: The object type, which is always `organization.project.service_account.api_key` + x-stainless-const: true value: type: string name: @@ -19467,6 +19524,7 @@ components: type: string enum: - organization.project.service_account + x-stainless-const: true id: type: string name: @@ -19476,6 +19534,7 @@ components: enum: - member description: Service accounts can only have one role of type `member` + x-stainless-const: true created_at: type: integer api_key: @@ -19494,6 +19553,7 @@ components: type: string enum: - organization.project.service_account.deleted + x-stainless-const: true id: type: string deleted: @@ -19509,6 +19569,7 @@ components: type: string enum: - list + x-stainless-const: true data: type: array items: @@ -19542,6 +19603,7 @@ components: enum: - organization.project.user description: The object type, which is always `organization.project.user` + x-stainless-const: true id: type: string description: The identifier, which can be referenced in API endpoints @@ -19600,6 +19662,7 @@ components: type: string enum: - organization.project.user.deleted + x-stainless-const: true id: type: string deleted: @@ -19668,6 +19731,7 @@ components: enum: - conversation.item.create description: The event type, must be `conversation.item.create`. + x-stainless-const: true previous_item_id: type: string description: > @@ -19675,13 +19739,16 @@ components: inserted. If not set, the new item will be appended to the end of the - conversation. + conversation. + + If set to `root`, the new item will be added to the beginning of the + conversation. - If set, it allows an item to be inserted mid-conversation. If the - ID + If set to an existing ID, it allows an item to be inserted + mid-conversation. If the - cannot be found, an error will be returned and the item will not be - added. + ID cannot be found, an error will be returned and the item will not + be added. item: $ref: "#/components/schemas/RealtimeConversationItem" required: @@ -19728,6 +19795,7 @@ components: enum: - conversation.item.delete description: The event type, must be `conversation.item.delete`. + x-stainless-const: true item_id: type: string description: The ID of the item to delete. @@ -19780,6 +19848,7 @@ components: enum: - conversation.item.truncate description: The event type, must be `conversation.item.truncate`. + x-stainless-const: true item_id: type: string description: > @@ -19853,6 +19922,7 @@ components: enum: - input_audio_buffer.append description: The event type, must be `input_audio_buffer.append`. + x-stainless-const: true audio: type: string description: > @@ -19886,6 +19956,7 @@ components: enum: - input_audio_buffer.clear description: The event type, must be `input_audio_buffer.clear`. + x-stainless-const: true required: - type x-oaiMeta: @@ -19932,6 +20003,7 @@ components: enum: - input_audio_buffer.commit description: The event type, must be `input_audio_buffer.commit`. + x-stainless-const: true required: - type x-oaiMeta: @@ -19961,6 +20033,7 @@ components: enum: - response.cancel description: The event type, must be `response.cancel`. + x-stainless-const: true response_id: type: string description: | @@ -20020,6 +20093,7 @@ components: enum: - response.create description: The event type, must be `response.create`. + x-stainless-const: true response: $ref: "#/components/schemas/RealtimeResponseCreateParams" required: @@ -20084,6 +20158,7 @@ components: enum: - session.update description: The event type, must be `session.update`. + x-stainless-const: true session: $ref: "#/components/schemas/RealtimeSessionCreateRequest" required: @@ -20162,6 +20237,7 @@ components: description: > Identifier for the API object being returned - always `realtime.item`. + x-stainless-const: true status: type: string enum: @@ -20272,6 +20348,7 @@ components: enum: - realtime.response description: The object type, must be `realtime.response`. + x-stainless-const: true status: type: string enum: @@ -20494,6 +20571,7 @@ components: enum: - function description: The type of the tool, i.e. `function`. + x-stainless-const: true name: type: string description: The name of the function. @@ -20529,6 +20607,7 @@ components: - type: string enum: - inf + x-stainless-const: true description: | Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to @@ -20596,6 +20675,7 @@ components: enum: - conversation.created description: The event type, must be `conversation.created`. + x-stainless-const: true conversation: type: object description: The conversation resource. @@ -20646,6 +20726,7 @@ components: enum: - conversation.item.created description: The event type, must be `conversation.item.created`. + x-stainless-const: true previous_item_id: type: string description: > @@ -20702,6 +20783,7 @@ components: enum: - conversation.item.deleted description: The event type, must be `conversation.item.deleted`. + x-stainless-const: true item_id: type: string description: The ID of the item that was deleted. @@ -20756,6 +20838,7 @@ components: description: | The event type, must be `conversation.item.input_audio_transcription.completed`. + x-stainless-const: true item_id: type: string description: The ID of the user message item containing the audio. @@ -20802,6 +20885,7 @@ components: description: | The event type, must be `conversation.item.input_audio_transcription.failed`. + x-stainless-const: true item_id: type: string description: The ID of the user message item. @@ -20872,6 +20956,7 @@ components: enum: - conversation.item.truncated description: The event type, must be `conversation.item.truncated`. + x-stainless-const: true item_id: type: string description: The ID of the assistant message item that was truncated. @@ -20917,6 +21002,7 @@ components: enum: - error description: The event type, must be `error`. + x-stainless-const: true error: type: object description: Details of the error. @@ -20979,6 +21065,7 @@ components: enum: - input_audio_buffer.cleared description: The event type, must be `input_audio_buffer.cleared`. + x-stainless-const: true required: - event_id - type @@ -21012,6 +21099,7 @@ components: enum: - input_audio_buffer.committed description: The event type, must be `input_audio_buffer.committed`. + x-stainless-const: true previous_item_id: type: string description: > @@ -21072,6 +21160,7 @@ components: enum: - input_audio_buffer.speech_started description: The event type, must be `input_audio_buffer.speech_started`. + x-stainless-const: true audio_start_ms: type: integer description: > @@ -21122,6 +21211,7 @@ components: enum: - input_audio_buffer.speech_stopped description: The event type, must be `input_audio_buffer.speech_stopped`. + x-stainless-const: true audio_end_ms: type: integer description: > @@ -21172,6 +21262,7 @@ components: enum: - rate_limits.updated description: The event type, must be `rate_limits.updated`. + x-stainless-const: true rate_limits: type: array description: List of rate limit information. @@ -21220,7 +21311,7 @@ components: } ] } - RealtimeServerEventOutputAudioDelta: + RealtimeServerEventResponseAudioDelta: type: object description: Returned when the model-generated audio is updated. properties: @@ -21232,6 +21323,7 @@ components: enum: - response.audio.delta description: The event type, must be `response.audio.delta`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21268,7 +21360,7 @@ components: "content_index": 0, "delta": "Base64EncodedAudioDelta" } - RealtimeServerEventOutputAudioDone: + RealtimeServerEventResponseAudioDone: type: object description: > Returned when the model-generated audio is done. Also emitted when a @@ -21284,6 +21376,7 @@ components: enum: - response.audio.done description: The event type, must be `response.audio.done`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21315,7 +21408,7 @@ components: "output_index": 0, "content_index": 0 } - RealtimeServerEventOutputAudioTranscriptDelta: + RealtimeServerEventResponseAudioTranscriptDelta: type: object description: > Returned when the model-generated transcription of audio output is @@ -21329,6 +21422,7 @@ components: enum: - response.audio_transcript.delta description: The event type, must be `response.audio_transcript.delta`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21365,7 +21459,7 @@ components: "content_index": 0, "delta": "Hello, how can I a" } - RealtimeServerEventOutputAudioTranscriptDone: + RealtimeServerEventResponseAudioTranscriptDone: type: object description: | Returned when the model-generated transcription of audio output is done @@ -21380,6 +21474,7 @@ components: enum: - response.audio_transcript.done description: The event type, must be `response.audio_transcript.done`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21432,6 +21527,7 @@ components: enum: - response.content_part.added description: The event type, must be `response.content_part.added`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21503,6 +21599,7 @@ components: enum: - response.content_part.done description: The event type, must be `response.content_part.done`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21574,6 +21671,7 @@ components: enum: - response.created description: The event type, must be `response.created`. + x-stainless-const: true response: $ref: "#/components/schemas/RealtimeResponse" required: @@ -21616,6 +21714,7 @@ components: enum: - response.done description: The event type, must be `response.done`. + x-stainless-const: true response: $ref: "#/components/schemas/RealtimeResponse" required: @@ -21683,6 +21782,7 @@ components: - response.function_call_arguments.delta description: | The event type, must be `response.function_call_arguments.delta`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21736,6 +21836,7 @@ components: - response.function_call_arguments.done description: | The event type, must be `response.function_call_arguments.done`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21784,6 +21885,7 @@ components: enum: - response.output_item.added description: The event type, must be `response.output_item.added`. + x-stainless-const: true response_id: type: string description: The ID of the Response to which the item belongs. @@ -21832,6 +21934,7 @@ components: enum: - response.output_item.done description: The event type, must be `response.output_item.done`. + x-stainless-const: true response_id: type: string description: The ID of the Response to which the item belongs. @@ -21881,6 +21984,7 @@ components: enum: - response.text.delta description: The event type, must be `response.text.delta`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21933,6 +22037,7 @@ components: enum: - response.text.done description: The event type, must be `response.text.done`. + x-stainless-const: true response_id: type: string description: The ID of the response. @@ -21987,6 +22092,7 @@ components: enum: - session.created description: The event type, must be `session.created`. + x-stainless-const: true session: $ref: "#/components/schemas/RealtimeSession" required: @@ -22038,6 +22144,7 @@ components: enum: - session.updated description: The event type, must be `session.updated`. + x-stainless-const: true session: $ref: "#/components/schemas/RealtimeSession" required: @@ -22162,6 +22269,10 @@ components: description: > The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + + For `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, + + single channel (mono), and little-endian byte order. output_audio_format: type: string enum: @@ -22171,6 +22282,8 @@ components: description: > The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + + For `pcm16`, output audio is sampled at a rate of 24kHz. input_audio_transcription: type: object description: > @@ -22213,6 +22326,7 @@ components: - server_vad description: > Type of turn detection, only `server_vad` is currently supported. + x-stainless-const: true threshold: type: number description: > @@ -22249,6 +22363,7 @@ components: enum: - function description: The type of the tool, i.e. `function`. + x-stainless-const: true name: type: string description: The name of the function. @@ -22283,6 +22398,7 @@ components: - type: string enum: - inf + x-stainless-const: true description: | Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to @@ -22291,8 +22407,6 @@ components: RealtimeSessionCreateRequest: type: object description: Realtime session object configuration. - required: - - model properties: modalities: description: | @@ -22376,6 +22490,10 @@ components: description: > The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + + For `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, + + single channel (mono), and little-endian byte order. output_audio_format: type: string enum: @@ -22385,6 +22503,8 @@ components: description: > The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + + For `pcm16`, output audio is sampled at a rate of 24kHz. input_audio_transcription: type: object description: > @@ -22466,6 +22586,7 @@ components: enum: - function description: The type of the tool, i.e. `function`. + x-stainless-const: true name: type: string description: The name of the function. @@ -22500,6 +22621,7 @@ components: - type: string enum: - inf + x-stainless-const: true description: | Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to @@ -22682,6 +22804,7 @@ components: enum: - function description: The type of the tool, i.e. `function`. + x-stainless-const: true name: type: string description: The name of the function. @@ -22716,6 +22839,7 @@ components: - type: string enum: - inf + x-stainless-const: true description: | Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to @@ -22755,6 +22879,7 @@ components: description: "The type of response format being defined: `json_object`" enum: - json_object + x-stainless-const: true required: - type ResponseFormatJsonSchema: @@ -22765,6 +22890,7 @@ components: description: "The type of response format being defined: `json_schema`" enum: - json_schema + x-stainless-const: true json_schema: type: object properties: @@ -22788,7 +22914,6 @@ components: Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). required: - - type - name required: - type @@ -22805,6 +22930,7 @@ components: description: "The type of response format being defined: `text`" enum: - text + x-stainless-const: true required: - type RunCompletionUsage: @@ -22839,6 +22965,7 @@ components: type: string enum: - thread.run + x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the run was created. type: integer @@ -22876,6 +23003,7 @@ components: type: string enum: - submit_tool_outputs + x-stainless-const: true submit_tool_outputs: type: object description: Details on the tool outputs needed for this run to continue. @@ -22998,16 +23126,19 @@ components: over the course of the run. minimum: 256 truncation_strategy: - $ref: "#/components/schemas/TruncationObject" - nullable: true + allOf: + - $ref: "#/components/schemas/TruncationObject" + - nullable: true tool_choice: - $ref: "#/components/schemas/AssistantsApiToolChoiceOption" - nullable: true + allOf: + - $ref: "#/components/schemas/AssistantsApiToolChoiceOption" + - nullable: true parallel_tool_calls: $ref: "#/components/schemas/ParallelToolCalls" response_format: - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" - nullable: true + allOf: + - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" + - nullable: true required: - id - object @@ -23108,6 +23239,7 @@ components: type: string enum: - thread.run.step.delta + x-stainless-const: true delta: description: The delta containing the fields that have changed on the run step. type: object @@ -23154,6 +23286,7 @@ components: type: string enum: - message_creation + x-stainless-const: true message_creation: type: object properties: @@ -23179,6 +23312,7 @@ components: `code_interpreter` for this type of tool call. enum: - code_interpreter + x-stainless-const: true code_interpreter: type: object description: The Code Interpreter tool call definition. @@ -23215,6 +23349,7 @@ components: type: string enum: - image + x-stainless-const: true image: type: object properties: @@ -23237,6 +23372,7 @@ components: type: string enum: - logs + x-stainless-const: true logs: type: string description: The text output from the Code Interpreter tool call. @@ -23259,6 +23395,7 @@ components: this type of tool call. enum: - file_search + x-stainless-const: true file_search: type: object description: For now, this is always going to be an empty object. @@ -23283,6 +23420,7 @@ components: this type of tool call. enum: - function + x-stainless-const: true function: type: object description: The definition of the function that was called. @@ -23312,6 +23450,7 @@ components: type: string enum: - tool_calls + x-stainless-const: true tool_calls: type: array description: > @@ -23336,6 +23475,7 @@ components: type: string enum: - message_creation + x-stainless-const: true message_creation: type: object properties: @@ -23361,6 +23501,7 @@ components: `code_interpreter` for this type of tool call. enum: - code_interpreter + x-stainless-const: true code_interpreter: type: object description: The Code Interpreter tool call definition. @@ -23396,6 +23537,7 @@ components: type: string enum: - image + x-stainless-const: true image: type: object properties: @@ -23417,6 +23559,7 @@ components: type: string enum: - logs + x-stainless-const: true logs: type: string description: The text output from the Code Interpreter tool call. @@ -23436,6 +23579,7 @@ components: this type of tool call. enum: - file_search + x-stainless-const: true file_search: type: object description: For now, this is always going to be an empty object. @@ -23463,6 +23607,7 @@ components: description: The ranker used for the file search. enum: - default_2024_08_21 + x-stainless-const: true score_threshold: type: number description: The score threshold for the file search. All values must be a @@ -23502,6 +23647,7 @@ components: description: The type of the content. enum: - text + x-stainless-const: true text: type: string description: The text content of the file. @@ -23522,6 +23668,7 @@ components: this type of tool call. enum: - function + x-stainless-const: true function: type: object description: The definition of the function that was called. @@ -23556,6 +23703,7 @@ components: type: string enum: - tool_calls + x-stainless-const: true tool_calls: type: array description: > @@ -23586,6 +23734,7 @@ components: type: string enum: - thread.run.step + x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the run step was created. type: integer @@ -23725,6 +23874,7 @@ components: type: string enum: - thread.run.step.created + x-stainless-const: true data: $ref: "#/components/schemas/RunStepObject" required: @@ -23740,6 +23890,7 @@ components: type: string enum: - thread.run.step.in_progress + x-stainless-const: true data: $ref: "#/components/schemas/RunStepObject" required: @@ -23755,6 +23906,7 @@ components: type: string enum: - thread.run.step.delta + x-stainless-const: true data: $ref: "#/components/schemas/RunStepDeltaObject" required: @@ -23772,6 +23924,7 @@ components: type: string enum: - thread.run.step.completed + x-stainless-const: true data: $ref: "#/components/schemas/RunStepObject" required: @@ -23787,6 +23940,7 @@ components: type: string enum: - thread.run.step.failed + x-stainless-const: true data: $ref: "#/components/schemas/RunStepObject" required: @@ -23802,6 +23956,7 @@ components: type: string enum: - thread.run.step.cancelled + x-stainless-const: true data: $ref: "#/components/schemas/RunStepObject" required: @@ -23817,6 +23972,7 @@ components: type: string enum: - thread.run.step.expired + x-stainless-const: true data: $ref: "#/components/schemas/RunStepObject" required: @@ -23834,6 +23990,7 @@ components: type: string enum: - thread.run.created + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23848,6 +24005,7 @@ components: type: string enum: - thread.run.queued + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23863,6 +24021,7 @@ components: type: string enum: - thread.run.in_progress + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23878,6 +24037,7 @@ components: type: string enum: - thread.run.requires_action + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23893,6 +24053,7 @@ components: type: string enum: - thread.run.completed + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23907,6 +24068,7 @@ components: type: string enum: - thread.run.incomplete + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23922,6 +24084,7 @@ components: type: string enum: - thread.run.failed + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23936,6 +24099,7 @@ components: type: string enum: - thread.run.cancelling + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23951,6 +24115,7 @@ components: type: string enum: - thread.run.cancelled + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23965,6 +24130,7 @@ components: type: string enum: - thread.run.expired + x-stainless-const: true data: $ref: "#/components/schemas/RunObject" required: @@ -23988,6 +24154,7 @@ components: always `function`. enum: - function + x-stainless-const: true function: type: object description: The function definition. @@ -24037,6 +24204,7 @@ components: description: Always `static`. enum: - static + x-stainless-const: true static: $ref: "#/components/schemas/StaticChunkingStrategy" required: @@ -24052,6 +24220,7 @@ components: description: Always `static`. enum: - static + x-stainless-const: true static: $ref: "#/components/schemas/StaticChunkingStrategy" required: @@ -24097,6 +24266,7 @@ components: type: string enum: - thread + x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the thread was created. type: integer @@ -24170,6 +24340,7 @@ components: type: string enum: - thread.created + x-stainless-const: true data: $ref: "#/components/schemas/ThreadObject" required: @@ -24286,8 +24457,9 @@ components: type: string nullable: true expires_after: - $ref: "#/components/schemas/VectorStoreExpirationAfter" - nullable: true + allOf: + - $ref: "#/components/schemas/VectorStoreExpirationAfter" + - nullable: true metadata: description: > Set of 16 key-value pairs that can be attached to an object. This @@ -24337,10 +24509,12 @@ components: description: The object type, which is always "upload". enum: - upload + x-stainless-const: true file: - $ref: "#/components/schemas/OpenAIFile" - nullable: true - description: The ready File object after the Upload is completed. + allOf: + - $ref: "#/components/schemas/OpenAIFile" + - nullable: true + description: The ready File object after the Upload is completed. required: - bytes - created_at @@ -24392,6 +24566,7 @@ components: description: The object type, which is always `upload.part`. enum: - upload.part + x-stainless-const: true required: - created_at - id @@ -24414,6 +24589,7 @@ components: type: string enum: - organization.usage.audio_speeches.result + x-stainless-const: true characters: type: integer description: The number of characters processed. @@ -24465,6 +24641,7 @@ components: type: string enum: - organization.usage.audio_transcriptions.result + x-stainless-const: true seconds: type: integer description: The number of seconds processed. @@ -24516,6 +24693,7 @@ components: type: string enum: - organization.usage.code_interpreter_sessions.result + x-stainless-const: true sessions: type: integer description: The number of code interpreter sessions. @@ -24543,6 +24721,7 @@ components: type: string enum: - organization.usage.completions.result + x-stainless-const: true input_tokens: type: integer description: The aggregated number of text input tokens used, including cached @@ -24622,6 +24801,7 @@ components: type: string enum: - organization.usage.embeddings.result + x-stainless-const: true input_tokens: type: integer description: The aggregated number of input tokens used. @@ -24672,6 +24852,7 @@ components: type: string enum: - organization.usage.images.result + x-stainless-const: true images: type: integer description: The number of images processed. @@ -24735,6 +24916,7 @@ components: type: string enum: - organization.usage.moderations.result + x-stainless-const: true input_tokens: type: integer description: The aggregated number of input tokens used. @@ -24784,6 +24966,7 @@ components: type: string enum: - page + x-stainless-const: true data: type: array items: @@ -24804,6 +24987,7 @@ components: type: string enum: - bucket + x-stainless-const: true start_time: type: integer end_time: @@ -24834,6 +25018,7 @@ components: type: string enum: - organization.usage.vector_stores.result + x-stainless-const: true usage_bytes: type: integer description: The vector stores usage in bytes. @@ -24862,6 +25047,7 @@ components: enum: - organization.user description: The object type, which is always `organization.user` + x-stainless-const: true id: type: string description: The identifier, which can be referenced in API endpoints @@ -24905,6 +25091,7 @@ components: type: string enum: - organization.user.deleted + x-stainless-const: true id: type: string deleted: @@ -24920,6 +25107,7 @@ components: type: string enum: - list + x-stainless-const: true data: type: array items: @@ -24958,6 +25146,7 @@ components: type: string enum: - last_active_at + x-stainless-const: true days: description: The number of days after the anchor time that the vector store will expire. @@ -24980,6 +25169,7 @@ components: type: string enum: - vector_store.files_batch + x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the vector store files batch was created. @@ -25060,6 +25250,7 @@ components: type: string enum: - vector_store.file + x-stainless-const: true usage_bytes: description: The total vector store usage in bytes. Note that this may be different from the original file size. @@ -25151,6 +25342,7 @@ components: type: string enum: - vector_store + x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the vector store was created. @@ -26146,16 +26338,16 @@ x-oaiMeta: key: RealtimeServerEventResponseTextDone path: - type: object - key: RealtimeServerEventOutputAudioTranscriptDelta + key: RealtimeServerEventResponseAudioTranscriptDelta path: - type: object - key: RealtimeServerEventOutputAudioTranscriptDone + key: RealtimeServerEventResponseAudioTranscriptDone path: - type: object - key: RealtimeServerEventOutputAudioDelta + key: RealtimeServerEventResponseAudioDelta path: - type: object - key: RealtimeServerEventOutputAudioDone + key: RealtimeServerEventResponseAudioDone path: - type: object key: RealtimeServerEventResponseFunctionCallArgumentsDelta From a33621ee4f8785ac3aa2ab2e1be02dd5c2502a4a Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 22 Jan 2025 16:02:17 -0800 Subject: [PATCH 21/44] small spec accuracy improvements (no code change) --- ...pi3-azure-openai-2024-06-01-generated.yaml | 636 +++-------- ...e-openai-2024-08-01-preview-generated.yaml | 636 +++-------- ...e-openai-2024-09-01-preview-generated.yaml | 636 +++-------- ...e-openai-2024-10-01-preview-generated.yaml | 671 +++--------- ...pi3-azure-openai-2024-10-21-generated.yaml | 753 +++---------- ...e-openai-2024-12-01-preview-generated.yaml | 808 ++++---------- ...e-openai-2025-01-01-preview-generated.yaml | 993 +++++++----------- .typespec.azure/chat/models.request.tsp | 23 + .typespec.azure/chat/operations.tsp | 2 +- .typespec.azure/tspconfig.yaml | 1 + 10 files changed, 1449 insertions(+), 3710 deletions(-) diff --git a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml index 301723362..1761788ab 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml @@ -82,6 +82,9 @@ paths: schema: anyOf: - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - type: array + items: + $ref: '#/components/schemas/AzureChatCompletionStreamResponseDelta' - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' tags: - Chat @@ -474,21 +477,6 @@ components: format: int32 required: - cached_tokens - AzureContentFilterBlocklistIdResult: - type: object - required: - - id - - filtered - properties: - id: - type: string - description: The ID of the custom blocklist associated with the filtered status. - filtered: - type: boolean - description: Whether the associated blocklist resulted in the content being filtered. - description: |- - A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not - the corresponding blocklist resulted in content being filtered. AzureContentFilterBlocklistResult: type: object required: @@ -585,90 +573,6 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. - AzureContentFilterResultForChoice: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - error: - type: object - properties: - code: - type: integer - format: int32 - description: A distinct, machine-readable code associated with the error. - message: - type: string - description: A human-readable message associated with the error. - required: - - code - - message - description: If present, details about an error that prevented content filtering from completing its evaluation. - protected_material_text: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: A detection result that describes a match against text protected under copyright or other status. - protected_material_code: - type: object - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - citation: - type: object - properties: - license: - type: string - description: The name or identifier of the license associated with the detection. - URL: - type: string - format: uri - description: The URL associated with the license. - description: If available, the citation details describing the associated license and its location. - required: - - filtered - - detected - description: A detection result that describes a match against licensed code or other protected source material. - description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -885,22 +789,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). + A list of messages comprising the conversation so far. Depending on the + [model](/docs/models) you use, different message types (modalities) are + supported, like [text](/docs/guides/text-generation), + [images](/docs/guides/vision), and [audio](/docs/guides/audio). frequency_penalty: type: number format: float @@ -908,9 +801,9 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + their existing frequency in the text so far, decreasing the model's + likelihood to repeat the same line verbatim. default: 0 logit_bias: type: object @@ -921,13 +814,21 @@ components: description: |- Modify the likelihood of specified tokens appearing in the completion. - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + Accepts a JSON object that maps tokens (specified by their token ID in the + tokenizer) to an associated bias value from -100 to 100. Mathematically, + the bias is added to the logits generated by the model prior to sampling. + The exact effect will vary per model, but values between -1 and 1 should + decrease or increase likelihood of selection; values like -100 or 100 + should result in a ban or exclusive selection of the relevant token. x-oaiTypeLabel: map default: null logprobs: type: boolean nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + description: |- + Whether to return log probabilities of the output tokens or not. If true, + returns the log probabilities of each output token returned in the + `content` of `message`. default: false top_logprobs: type: integer @@ -935,15 +836,21 @@ components: nullable: true minimum: 0 maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + description: |- + An integer between 0 and 20 specifying the number of most likely tokens to + return at each token position, each with an associated log probability. + `logprobs` must be set to `true` if this parameter is used. max_tokens: type: integer format: int32 nullable: true description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + The maximum number of [tokens](/tokenizer) that can be generated in the + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + This value is now deprecated in favor of `max_completion_tokens`, and is + not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true max_completion_tokens: type: integer @@ -965,28 +872,36 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + whether they appear in the text so far, increasing the model's likelihood + to talk about new topics. default: 0 response_format: allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + An object specifying the format that the model must output. - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + **Important:** when using JSON mode, you **must** also instruct the model + to produce JSON yourself via a system or user message. Without this, the + model may generate an unending stream of whitespace until the generation + reaches the token limit, resulting in a long-running and seemingly "stuck" + request. Also note that the message content may be partially cut off if + `finish_reason="length"`, which indicates the generation exceeded + `max_tokens` or the conversation exceeded the max context length. x-oaiExpandable: true seed: type: integer format: int64 nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 description: |- This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. @@ -1019,7 +934,6 @@ components: maximum: 2 description: |- What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. default: 1 top_p: @@ -1029,7 +943,10 @@ components: minimum: 0 maximum: 1 description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + An alternative to sampling with temperature, called nucleus sampling, + where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass + are considered. We generally recommend altering this or `temperature` but not both. default: 1 @@ -1045,7 +962,7 @@ components: default: true user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). function_call: anyOf: - type: string @@ -1057,11 +974,18 @@ components: Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - `none` is the default when no functions are present. `auto` is the default if functions are present. + `none` means the model will not call a function and instead generates a + message. + + `auto` means the model can pick between generating a message or calling a + function. + + Specifying a particular function via `{"name": "my_function"}` forces the + model to call that function. + + `none` is the default when no functions are present. `auto` is the default + if functions are present. deprecated: true x-oaiExpandable: true functions: @@ -1161,7 +1085,7 @@ components: - scale - default nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + description: The service tier used for processing the request. system_fingerprint: type: string description: |- @@ -1371,17 +1295,6 @@ components: error: $ref: '#/components/schemas/AzureOpenAIDalleError' description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - - 2025-01-01-preview - description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object required: @@ -1524,321 +1437,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytesItem: + ChatCompletionTokenLogprobBytes: type: array items: type: integer format: int32 - CompletionUsageCommonBase: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - description: Usage statistics for the completion request. - CreateChatCompletionRequestCommonBase: - type: object - required: - - messages - properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - stop: - anyOf: - - type: string - - type: array - items: - type: string - nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean - nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true - user: - type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. - deprecated: true - x-oaiExpandable: true - functions: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - CreateChatCompletionResponseCommonBase: - type: object - required: - - id - - choices - - created - - model - - object - properties: - id: - type: string - description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: - type: string - description: The model used for the chat completion. - service_tier: - type: string - enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: - type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - enum: - - chat.completion - description: The object type, which is always `chat.completion`. - description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -2023,7 +1626,7 @@ components: description: |- The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' description: Overrides for the file search tool. @@ -2077,6 +1680,19 @@ components: parameters: $ref: '#/components/schemas/OpenAI.FunctionParameters' deprecated: true + OpenAI.ChatCompletionMessageAudioChunk: + type: object + properties: + id: + type: string + transcript: + type: string + data: + type: string + format: base64 + expires_at: + type: integer + format: unixtime OpenAI.ChatCompletionMessageToolCall: type: object required: @@ -2176,6 +1792,19 @@ components: name: type: string description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + audio: + type: object + properties: + id: + type: string + description: Unique identifier for a previous audio response from the model. + required: + - id + nullable: true + description: |- + Data about a previous audio response from the model. + [Learn more](/docs/guides/audio). + x-oaiExpandable: true tool_calls: $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: @@ -2193,6 +1822,7 @@ components: deprecated: true allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: Messages sent by the model in response to user messages. OpenAI.ChatCompletionRequestAssistantMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' @@ -2237,6 +1867,34 @@ components: tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartAudio: + type: object + required: + - type + - input_audio + properties: + type: + type: string + enum: + - input_audio + description: The type of the content part. Always `input_audio`. + input_audio: + type: object + properties: + data: + type: string + format: base64 + description: Base64 encoded audio data. + format: + type: string + enum: + - wav + - mp3 + description: The format of the encoded audio data. Currently supports "wav" and "mp3". + required: + - data + - format + description: Learn about [audio inputs](/docs/guides/audio). OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: @@ -2261,10 +1919,11 @@ components: - auto - low - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). default: auto required: - url + description: Learn about [image inputs](/docs/guides/vision). OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: @@ -2293,6 +1952,7 @@ components: text: type: string description: The text content. + description: Learn about [text inputs](/docs/guides/text-generation). OpenAI.ChatCompletionRequestSystemMessage: type: object required: @@ -2316,6 +1976,10 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. OpenAI.ChatCompletionRequestSystemMessageContentPart: type: object allOf: @@ -2374,10 +2038,14 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Messages sent by an end user, containing prompts or additional context + information. OpenAI.ChatCompletionRequestUserMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartAudio' x-oaiExpandable: true OpenAI.ChatCompletionResponseMessage: type: object @@ -2413,6 +2081,38 @@ components: - arguments description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true + audio: + type: object + properties: + id: + type: string + description: Unique identifier for this audio response. + expires_at: + type: integer + format: unixtime + description: |- + The Unix timestamp (in seconds) for when this audio response will + no longer be accessible on the server for use in multi-turn + conversations. + data: + type: string + format: base64 + description: |- + Base64 encoded audio bytes generated by the model, in the format + specified in the request. + transcript: + type: string + description: Transcript of the audio generated by the model. + required: + - id + - expires_at + - data + - transcript + nullable: true + description: |- + If the audio output modality is requested, this object contains data + about the audio response from the model. [Learn more](/docs/guides/audio). + x-oaiExpandable: true description: A chat completion message generated by the model. OpenAI.ChatCompletionStreamOptions: type: object @@ -2424,6 +2124,10 @@ components: OpenAI.ChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. content: type: string nullable: true @@ -2472,7 +2176,7 @@ components: bytes: type: object allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2660,7 +2364,7 @@ components: default: vivid user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). OpenAI.CreateMessageRequest: type: object required: @@ -2739,7 +2443,7 @@ components: description: |- The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. OpenAI.FunctionObject: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml index 29c642bb8..2805ab4ae 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml @@ -82,6 +82,9 @@ paths: schema: anyOf: - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - type: array + items: + $ref: '#/components/schemas/AzureChatCompletionStreamResponseDelta' - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' tags: - Chat @@ -506,21 +509,6 @@ components: format: int32 required: - cached_tokens - AzureContentFilterBlocklistIdResult: - type: object - required: - - id - - filtered - properties: - id: - type: string - description: The ID of the custom blocklist associated with the filtered status. - filtered: - type: boolean - description: Whether the associated blocklist resulted in the content being filtered. - description: |- - A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not - the corresponding blocklist resulted in content being filtered. AzureContentFilterBlocklistResult: type: object required: @@ -617,90 +605,6 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. - AzureContentFilterResultForChoice: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - error: - type: object - properties: - code: - type: integer - format: int32 - description: A distinct, machine-readable code associated with the error. - message: - type: string - description: A human-readable message associated with the error. - required: - - code - - message - description: If present, details about an error that prevented content filtering from completing its evaluation. - protected_material_text: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: A detection result that describes a match against text protected under copyright or other status. - protected_material_code: - type: object - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - citation: - type: object - properties: - license: - type: string - description: The name or identifier of the license associated with the detection. - URL: - type: string - format: uri - description: The URL associated with the license. - description: If available, the citation details describing the associated license and its location. - required: - - filtered - - detected - description: A detection result that describes a match against licensed code or other protected source material. - description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -911,22 +815,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). + A list of messages comprising the conversation so far. Depending on the + [model](/docs/models) you use, different message types (modalities) are + supported, like [text](/docs/guides/text-generation), + [images](/docs/guides/vision), and [audio](/docs/guides/audio). frequency_penalty: type: number format: float @@ -934,9 +827,9 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + their existing frequency in the text so far, decreasing the model's + likelihood to repeat the same line verbatim. default: 0 logit_bias: type: object @@ -947,13 +840,21 @@ components: description: |- Modify the likelihood of specified tokens appearing in the completion. - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + Accepts a JSON object that maps tokens (specified by their token ID in the + tokenizer) to an associated bias value from -100 to 100. Mathematically, + the bias is added to the logits generated by the model prior to sampling. + The exact effect will vary per model, but values between -1 and 1 should + decrease or increase likelihood of selection; values like -100 or 100 + should result in a ban or exclusive selection of the relevant token. x-oaiTypeLabel: map default: null logprobs: type: boolean nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + description: |- + Whether to return log probabilities of the output tokens or not. If true, + returns the log probabilities of each output token returned in the + `content` of `message`. default: false top_logprobs: type: integer @@ -961,15 +862,21 @@ components: nullable: true minimum: 0 maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + description: |- + An integer between 0 and 20 specifying the number of most likely tokens to + return at each token position, each with an associated log probability. + `logprobs` must be set to `true` if this parameter is used. max_tokens: type: integer format: int32 nullable: true description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + The maximum number of [tokens](/tokenizer) that can be generated in the + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + This value is now deprecated in favor of `max_completion_tokens`, and is + not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true max_completion_tokens: type: integer @@ -991,28 +898,36 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + whether they appear in the text so far, increasing the model's likelihood + to talk about new topics. default: 0 response_format: allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + An object specifying the format that the model must output. - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + **Important:** when using JSON mode, you **must** also instruct the model + to produce JSON yourself via a system or user message. Without this, the + model may generate an unending stream of whitespace until the generation + reaches the token limit, resulting in a long-running and seemingly "stuck" + request. Also note that the message content may be partially cut off if + `finish_reason="length"`, which indicates the generation exceeded + `max_tokens` or the conversation exceeded the max context length. x-oaiExpandable: true seed: type: integer format: int64 nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 description: |- This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. @@ -1045,7 +960,6 @@ components: maximum: 2 description: |- What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. default: 1 top_p: @@ -1055,7 +969,10 @@ components: minimum: 0 maximum: 1 description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + An alternative to sampling with temperature, called nucleus sampling, + where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass + are considered. We generally recommend altering this or `temperature` but not both. default: 1 @@ -1071,7 +988,7 @@ components: default: true user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). function_call: anyOf: - type: string @@ -1083,11 +1000,18 @@ components: Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - `none` is the default when no functions are present. `auto` is the default if functions are present. + `none` means the model will not call a function and instead generates a + message. + + `auto` means the model can pick between generating a message or calling a + function. + + Specifying a particular function via `{"name": "my_function"}` forces the + model to call that function. + + `none` is the default when no functions are present. `auto` is the default + if functions are present. deprecated: true x-oaiExpandable: true functions: @@ -1187,7 +1111,7 @@ components: - scale - default nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + description: The service tier used for processing the request. system_fingerprint: type: string description: |- @@ -1309,17 +1233,6 @@ components: error: $ref: '#/components/schemas/AzureOpenAIDalleError' description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - - 2025-01-01-preview - description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object required: @@ -1457,321 +1370,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytesItem: + ChatCompletionTokenLogprobBytes: type: array items: type: integer format: int32 - CompletionUsageCommonBase: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - description: Usage statistics for the completion request. - CreateChatCompletionRequestCommonBase: - type: object - required: - - messages - properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - stop: - anyOf: - - type: string - - type: array - items: - type: string - nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean - nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true - user: - type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. - deprecated: true - x-oaiExpandable: true - functions: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - CreateChatCompletionResponseCommonBase: - type: object - required: - - id - - choices - - created - - model - - object - properties: - id: - type: string - description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: - type: string - description: The model used for the chat completion. - service_tier: - type: string - enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: - type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - enum: - - chat.completion - description: The object type, which is always `chat.completion`. - description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -2071,7 +1674,7 @@ components: description: |- The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' description: Overrides for the file search tool. @@ -2125,6 +1728,19 @@ components: parameters: $ref: '#/components/schemas/OpenAI.FunctionParameters' deprecated: true + OpenAI.ChatCompletionMessageAudioChunk: + type: object + properties: + id: + type: string + transcript: + type: string + data: + type: string + format: base64 + expires_at: + type: integer + format: unixtime OpenAI.ChatCompletionMessageToolCall: type: object required: @@ -2224,6 +1840,19 @@ components: name: type: string description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + audio: + type: object + properties: + id: + type: string + description: Unique identifier for a previous audio response from the model. + required: + - id + nullable: true + description: |- + Data about a previous audio response from the model. + [Learn more](/docs/guides/audio). + x-oaiExpandable: true tool_calls: $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: @@ -2241,6 +1870,7 @@ components: deprecated: true allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: Messages sent by the model in response to user messages. OpenAI.ChatCompletionRequestAssistantMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' @@ -2285,6 +1915,34 @@ components: tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartAudio: + type: object + required: + - type + - input_audio + properties: + type: + type: string + enum: + - input_audio + description: The type of the content part. Always `input_audio`. + input_audio: + type: object + properties: + data: + type: string + format: base64 + description: Base64 encoded audio data. + format: + type: string + enum: + - wav + - mp3 + description: The format of the encoded audio data. Currently supports "wav" and "mp3". + required: + - data + - format + description: Learn about [audio inputs](/docs/guides/audio). OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: @@ -2309,10 +1967,11 @@ components: - auto - low - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). default: auto required: - url + description: Learn about [image inputs](/docs/guides/vision). OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: @@ -2341,6 +2000,7 @@ components: text: type: string description: The text content. + description: Learn about [text inputs](/docs/guides/text-generation). OpenAI.ChatCompletionRequestSystemMessage: type: object required: @@ -2364,6 +2024,10 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. OpenAI.ChatCompletionRequestSystemMessageContentPart: type: object allOf: @@ -2422,10 +2086,14 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Messages sent by an end user, containing prompts or additional context + information. OpenAI.ChatCompletionRequestUserMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartAudio' x-oaiExpandable: true OpenAI.ChatCompletionResponseMessage: type: object @@ -2461,6 +2129,38 @@ components: - arguments description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true + audio: + type: object + properties: + id: + type: string + description: Unique identifier for this audio response. + expires_at: + type: integer + format: unixtime + description: |- + The Unix timestamp (in seconds) for when this audio response will + no longer be accessible on the server for use in multi-turn + conversations. + data: + type: string + format: base64 + description: |- + Base64 encoded audio bytes generated by the model, in the format + specified in the request. + transcript: + type: string + description: Transcript of the audio generated by the model. + required: + - id + - expires_at + - data + - transcript + nullable: true + description: |- + If the audio output modality is requested, this object contains data + about the audio response from the model. [Learn more](/docs/guides/audio). + x-oaiExpandable: true description: A chat completion message generated by the model. OpenAI.ChatCompletionStreamOptions: type: object @@ -2472,6 +2172,10 @@ components: OpenAI.ChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. content: type: string nullable: true @@ -2520,7 +2224,7 @@ components: bytes: type: object allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2708,7 +2412,7 @@ components: default: vivid user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). OpenAI.CreateMessageRequest: type: object required: @@ -2787,7 +2491,7 @@ components: description: |- The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. OpenAI.FunctionObject: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml index 755260df4..fc2a322ca 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml @@ -82,6 +82,9 @@ paths: schema: anyOf: - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - type: array + items: + $ref: '#/components/schemas/AzureChatCompletionStreamResponseDelta' - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' tags: - Chat @@ -506,21 +509,6 @@ components: format: int32 required: - cached_tokens - AzureContentFilterBlocklistIdResult: - type: object - required: - - id - - filtered - properties: - id: - type: string - description: The ID of the custom blocklist associated with the filtered status. - filtered: - type: boolean - description: Whether the associated blocklist resulted in the content being filtered. - description: |- - A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not - the corresponding blocklist resulted in content being filtered. AzureContentFilterBlocklistResult: type: object required: @@ -617,90 +605,6 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. - AzureContentFilterResultForChoice: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - error: - type: object - properties: - code: - type: integer - format: int32 - description: A distinct, machine-readable code associated with the error. - message: - type: string - description: A human-readable message associated with the error. - required: - - code - - message - description: If present, details about an error that prevented content filtering from completing its evaluation. - protected_material_text: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: A detection result that describes a match against text protected under copyright or other status. - protected_material_code: - type: object - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - citation: - type: object - properties: - license: - type: string - description: The name or identifier of the license associated with the detection. - URL: - type: string - format: uri - description: The URL associated with the license. - description: If available, the citation details describing the associated license and its location. - required: - - filtered - - detected - description: A detection result that describes a match against licensed code or other protected source material. - description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -911,22 +815,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). + A list of messages comprising the conversation so far. Depending on the + [model](/docs/models) you use, different message types (modalities) are + supported, like [text](/docs/guides/text-generation), + [images](/docs/guides/vision), and [audio](/docs/guides/audio). frequency_penalty: type: number format: float @@ -934,9 +827,9 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + their existing frequency in the text so far, decreasing the model's + likelihood to repeat the same line verbatim. default: 0 logit_bias: type: object @@ -947,13 +840,21 @@ components: description: |- Modify the likelihood of specified tokens appearing in the completion. - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + Accepts a JSON object that maps tokens (specified by their token ID in the + tokenizer) to an associated bias value from -100 to 100. Mathematically, + the bias is added to the logits generated by the model prior to sampling. + The exact effect will vary per model, but values between -1 and 1 should + decrease or increase likelihood of selection; values like -100 or 100 + should result in a ban or exclusive selection of the relevant token. x-oaiTypeLabel: map default: null logprobs: type: boolean nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + description: |- + Whether to return log probabilities of the output tokens or not. If true, + returns the log probabilities of each output token returned in the + `content` of `message`. default: false top_logprobs: type: integer @@ -961,15 +862,21 @@ components: nullable: true minimum: 0 maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + description: |- + An integer between 0 and 20 specifying the number of most likely tokens to + return at each token position, each with an associated log probability. + `logprobs` must be set to `true` if this parameter is used. max_tokens: type: integer format: int32 nullable: true description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + The maximum number of [tokens](/tokenizer) that can be generated in the + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + This value is now deprecated in favor of `max_completion_tokens`, and is + not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true max_completion_tokens: type: integer @@ -991,28 +898,36 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + whether they appear in the text so far, increasing the model's likelihood + to talk about new topics. default: 0 response_format: allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + An object specifying the format that the model must output. - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + **Important:** when using JSON mode, you **must** also instruct the model + to produce JSON yourself via a system or user message. Without this, the + model may generate an unending stream of whitespace until the generation + reaches the token limit, resulting in a long-running and seemingly "stuck" + request. Also note that the message content may be partially cut off if + `finish_reason="length"`, which indicates the generation exceeded + `max_tokens` or the conversation exceeded the max context length. x-oaiExpandable: true seed: type: integer format: int64 nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 description: |- This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. @@ -1045,7 +960,6 @@ components: maximum: 2 description: |- What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. default: 1 top_p: @@ -1055,7 +969,10 @@ components: minimum: 0 maximum: 1 description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + An alternative to sampling with temperature, called nucleus sampling, + where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass + are considered. We generally recommend altering this or `temperature` but not both. default: 1 @@ -1071,7 +988,7 @@ components: default: true user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). function_call: anyOf: - type: string @@ -1083,11 +1000,18 @@ components: Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - `none` is the default when no functions are present. `auto` is the default if functions are present. + `none` means the model will not call a function and instead generates a + message. + + `auto` means the model can pick between generating a message or calling a + function. + + Specifying a particular function via `{"name": "my_function"}` forces the + model to call that function. + + `none` is the default when no functions are present. `auto` is the default + if functions are present. deprecated: true x-oaiExpandable: true functions: @@ -1187,7 +1111,7 @@ components: - scale - default nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + description: The service tier used for processing the request. system_fingerprint: type: string description: |- @@ -1309,17 +1233,6 @@ components: error: $ref: '#/components/schemas/AzureOpenAIDalleError' description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - - 2025-01-01-preview - description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object required: @@ -1457,321 +1370,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytesItem: + ChatCompletionTokenLogprobBytes: type: array items: type: integer format: int32 - CompletionUsageCommonBase: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - description: Usage statistics for the completion request. - CreateChatCompletionRequestCommonBase: - type: object - required: - - messages - properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - stop: - anyOf: - - type: string - - type: array - items: - type: string - nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean - nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true - user: - type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. - deprecated: true - x-oaiExpandable: true - functions: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - CreateChatCompletionResponseCommonBase: - type: object - required: - - id - - choices - - created - - model - - object - properties: - id: - type: string - description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: - type: string - description: The model used for the chat completion. - service_tier: - type: string - enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: - type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - enum: - - chat.completion - description: The object type, which is always `chat.completion`. - description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -2071,7 +1674,7 @@ components: description: |- The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' description: Overrides for the file search tool. @@ -2125,6 +1728,19 @@ components: parameters: $ref: '#/components/schemas/OpenAI.FunctionParameters' deprecated: true + OpenAI.ChatCompletionMessageAudioChunk: + type: object + properties: + id: + type: string + transcript: + type: string + data: + type: string + format: base64 + expires_at: + type: integer + format: unixtime OpenAI.ChatCompletionMessageToolCall: type: object required: @@ -2224,6 +1840,19 @@ components: name: type: string description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + audio: + type: object + properties: + id: + type: string + description: Unique identifier for a previous audio response from the model. + required: + - id + nullable: true + description: |- + Data about a previous audio response from the model. + [Learn more](/docs/guides/audio). + x-oaiExpandable: true tool_calls: $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: @@ -2241,6 +1870,7 @@ components: deprecated: true allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: Messages sent by the model in response to user messages. OpenAI.ChatCompletionRequestAssistantMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' @@ -2285,6 +1915,34 @@ components: tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartAudio: + type: object + required: + - type + - input_audio + properties: + type: + type: string + enum: + - input_audio + description: The type of the content part. Always `input_audio`. + input_audio: + type: object + properties: + data: + type: string + format: base64 + description: Base64 encoded audio data. + format: + type: string + enum: + - wav + - mp3 + description: The format of the encoded audio data. Currently supports "wav" and "mp3". + required: + - data + - format + description: Learn about [audio inputs](/docs/guides/audio). OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: @@ -2309,10 +1967,11 @@ components: - auto - low - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). default: auto required: - url + description: Learn about [image inputs](/docs/guides/vision). OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: @@ -2341,6 +2000,7 @@ components: text: type: string description: The text content. + description: Learn about [text inputs](/docs/guides/text-generation). OpenAI.ChatCompletionRequestSystemMessage: type: object required: @@ -2364,6 +2024,10 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. OpenAI.ChatCompletionRequestSystemMessageContentPart: type: object allOf: @@ -2422,10 +2086,14 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Messages sent by an end user, containing prompts or additional context + information. OpenAI.ChatCompletionRequestUserMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartAudio' x-oaiExpandable: true OpenAI.ChatCompletionResponseMessage: type: object @@ -2461,6 +2129,38 @@ components: - arguments description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true + audio: + type: object + properties: + id: + type: string + description: Unique identifier for this audio response. + expires_at: + type: integer + format: unixtime + description: |- + The Unix timestamp (in seconds) for when this audio response will + no longer be accessible on the server for use in multi-turn + conversations. + data: + type: string + format: base64 + description: |- + Base64 encoded audio bytes generated by the model, in the format + specified in the request. + transcript: + type: string + description: Transcript of the audio generated by the model. + required: + - id + - expires_at + - data + - transcript + nullable: true + description: |- + If the audio output modality is requested, this object contains data + about the audio response from the model. [Learn more](/docs/guides/audio). + x-oaiExpandable: true description: A chat completion message generated by the model. OpenAI.ChatCompletionStreamOptions: type: object @@ -2472,6 +2172,10 @@ components: OpenAI.ChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. content: type: string nullable: true @@ -2520,7 +2224,7 @@ components: bytes: type: object allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2708,7 +2412,7 @@ components: default: vivid user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). OpenAI.CreateMessageRequest: type: object required: @@ -2787,7 +2491,7 @@ components: description: |- The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. OpenAI.FunctionObject: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml index 4ec436e96..78400d623 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml @@ -82,6 +82,9 @@ paths: schema: anyOf: - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - type: array + items: + $ref: '#/components/schemas/AzureChatCompletionStreamResponseDelta' - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' tags: - Chat @@ -506,21 +509,6 @@ components: format: int32 required: - cached_tokens - AzureContentFilterBlocklistIdResult: - type: object - required: - - id - - filtered - properties: - id: - type: string - description: The ID of the custom blocklist associated with the filtered status. - filtered: - type: boolean - description: Whether the associated blocklist resulted in the content being filtered. - description: |- - A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not - the corresponding blocklist resulted in content being filtered. AzureContentFilterBlocklistResult: type: object required: @@ -545,39 +533,6 @@ components: - id description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. description: A collection of true/false filtering results for configured custom blocklists. - AzureContentFilterCompletionTextSpan: - type: object - required: - - completion_start_offset - - completion_end_offset - properties: - completion_start_offset: - type: integer - format: int32 - description: Offset of the UTF32 code point which begins the span. - completion_end_offset: - type: integer - format: int32 - description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. - description: A representation of a span of completion text as used by Azure OpenAI content filter results. - AzureContentFilterCompletionTextSpanDetectionResult: - type: object - required: - - filtered - - detected - - details - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - details: - type: array - items: - $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' - description: Detailed information about the detected completion text spans. AzureContentFilterDetectionResult: type: object required: @@ -650,92 +605,6 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. - AzureContentFilterResultForChoice: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - error: - type: object - properties: - code: - type: integer - format: int32 - description: A distinct, machine-readable code associated with the error. - message: - type: string - description: A human-readable message associated with the error. - required: - - code - - message - description: If present, details about an error that prevented content filtering from completing its evaluation. - protected_material_text: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: A detection result that describes a match against text protected under copyright or other status. - protected_material_code: - type: object - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - citation: - type: object - properties: - license: - type: string - description: The name or identifier of the license associated with the detection. - URL: - type: string - format: uri - description: The URL associated with the license. - description: If available, the citation details describing the associated license and its location. - required: - - filtered - - detected - description: A detection result that describes a match against licensed code or other protected source material. - ungrounded_material: - $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' - description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -946,22 +815,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). + A list of messages comprising the conversation so far. Depending on the + [model](/docs/models) you use, different message types (modalities) are + supported, like [text](/docs/guides/text-generation), + [images](/docs/guides/vision), and [audio](/docs/guides/audio). frequency_penalty: type: number format: float @@ -969,9 +827,9 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + their existing frequency in the text so far, decreasing the model's + likelihood to repeat the same line verbatim. default: 0 logit_bias: type: object @@ -982,13 +840,21 @@ components: description: |- Modify the likelihood of specified tokens appearing in the completion. - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + Accepts a JSON object that maps tokens (specified by their token ID in the + tokenizer) to an associated bias value from -100 to 100. Mathematically, + the bias is added to the logits generated by the model prior to sampling. + The exact effect will vary per model, but values between -1 and 1 should + decrease or increase likelihood of selection; values like -100 or 100 + should result in a ban or exclusive selection of the relevant token. x-oaiTypeLabel: map default: null logprobs: type: boolean nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + description: |- + Whether to return log probabilities of the output tokens or not. If true, + returns the log probabilities of each output token returned in the + `content` of `message`. default: false top_logprobs: type: integer @@ -996,15 +862,21 @@ components: nullable: true minimum: 0 maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + description: |- + An integer between 0 and 20 specifying the number of most likely tokens to + return at each token position, each with an associated log probability. + `logprobs` must be set to `true` if this parameter is used. max_tokens: type: integer format: int32 nullable: true description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + The maximum number of [tokens](/tokenizer) that can be generated in the + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + This value is now deprecated in favor of `max_completion_tokens`, and is + not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true max_completion_tokens: type: integer @@ -1026,28 +898,36 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + whether they appear in the text so far, increasing the model's likelihood + to talk about new topics. default: 0 response_format: allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + An object specifying the format that the model must output. - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + **Important:** when using JSON mode, you **must** also instruct the model + to produce JSON yourself via a system or user message. Without this, the + model may generate an unending stream of whitespace until the generation + reaches the token limit, resulting in a long-running and seemingly "stuck" + request. Also note that the message content may be partially cut off if + `finish_reason="length"`, which indicates the generation exceeded + `max_tokens` or the conversation exceeded the max context length. x-oaiExpandable: true seed: type: integer format: int64 nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 description: |- This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. @@ -1080,7 +960,6 @@ components: maximum: 2 description: |- What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. default: 1 top_p: @@ -1090,7 +969,10 @@ components: minimum: 0 maximum: 1 description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + An alternative to sampling with temperature, called nucleus sampling, + where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass + are considered. We generally recommend altering this or `temperature` but not both. default: 1 @@ -1106,7 +988,7 @@ components: default: true user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). function_call: anyOf: - type: string @@ -1118,11 +1000,18 @@ components: Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - `none` is the default when no functions are present. `auto` is the default if functions are present. + `none` means the model will not call a function and instead generates a + message. + + `auto` means the model can pick between generating a message or calling a + function. + + Specifying a particular function via `{"name": "my_function"}` forces the + model to call that function. + + `none` is the default when no functions are present. `auto` is the default + if functions are present. deprecated: true x-oaiExpandable: true functions: @@ -1222,7 +1111,7 @@ components: - scale - default nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + description: The service tier used for processing the request. system_fingerprint: type: string description: |- @@ -1344,17 +1233,6 @@ components: error: $ref: '#/components/schemas/AzureOpenAIDalleError' description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - - 2025-01-01-preview - description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object required: @@ -1492,321 +1370,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytesItem: + ChatCompletionTokenLogprobBytes: type: array items: type: integer format: int32 - CompletionUsageCommonBase: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - description: Usage statistics for the completion request. - CreateChatCompletionRequestCommonBase: - type: object - required: - - messages - properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - stop: - anyOf: - - type: string - - type: array - items: - type: string - nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean - nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true - user: - type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. - deprecated: true - x-oaiExpandable: true - functions: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - CreateChatCompletionResponseCommonBase: - type: object - required: - - id - - choices - - created - - model - - object - properties: - id: - type: string - description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: - type: string - description: The model used for the chat completion. - service_tier: - type: string - enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: - type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - enum: - - chat.completion - description: The object type, which is always `chat.completion`. - description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -2106,7 +1674,7 @@ components: description: |- The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' description: Overrides for the file search tool. @@ -2160,6 +1728,19 @@ components: parameters: $ref: '#/components/schemas/OpenAI.FunctionParameters' deprecated: true + OpenAI.ChatCompletionMessageAudioChunk: + type: object + properties: + id: + type: string + transcript: + type: string + data: + type: string + format: base64 + expires_at: + type: integer + format: unixtime OpenAI.ChatCompletionMessageToolCall: type: object required: @@ -2259,6 +1840,19 @@ components: name: type: string description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + audio: + type: object + properties: + id: + type: string + description: Unique identifier for a previous audio response from the model. + required: + - id + nullable: true + description: |- + Data about a previous audio response from the model. + [Learn more](/docs/guides/audio). + x-oaiExpandable: true tool_calls: $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: @@ -2276,6 +1870,7 @@ components: deprecated: true allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: Messages sent by the model in response to user messages. OpenAI.ChatCompletionRequestAssistantMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' @@ -2320,6 +1915,34 @@ components: tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartAudio: + type: object + required: + - type + - input_audio + properties: + type: + type: string + enum: + - input_audio + description: The type of the content part. Always `input_audio`. + input_audio: + type: object + properties: + data: + type: string + format: base64 + description: Base64 encoded audio data. + format: + type: string + enum: + - wav + - mp3 + description: The format of the encoded audio data. Currently supports "wav" and "mp3". + required: + - data + - format + description: Learn about [audio inputs](/docs/guides/audio). OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: @@ -2344,10 +1967,11 @@ components: - auto - low - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). default: auto required: - url + description: Learn about [image inputs](/docs/guides/vision). OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: @@ -2376,6 +2000,7 @@ components: text: type: string description: The text content. + description: Learn about [text inputs](/docs/guides/text-generation). OpenAI.ChatCompletionRequestSystemMessage: type: object required: @@ -2399,6 +2024,10 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. OpenAI.ChatCompletionRequestSystemMessageContentPart: type: object allOf: @@ -2457,10 +2086,14 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Messages sent by an end user, containing prompts or additional context + information. OpenAI.ChatCompletionRequestUserMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartAudio' x-oaiExpandable: true OpenAI.ChatCompletionResponseMessage: type: object @@ -2496,6 +2129,38 @@ components: - arguments description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true + audio: + type: object + properties: + id: + type: string + description: Unique identifier for this audio response. + expires_at: + type: integer + format: unixtime + description: |- + The Unix timestamp (in seconds) for when this audio response will + no longer be accessible on the server for use in multi-turn + conversations. + data: + type: string + format: base64 + description: |- + Base64 encoded audio bytes generated by the model, in the format + specified in the request. + transcript: + type: string + description: Transcript of the audio generated by the model. + required: + - id + - expires_at + - data + - transcript + nullable: true + description: |- + If the audio output modality is requested, this object contains data + about the audio response from the model. [Learn more](/docs/guides/audio). + x-oaiExpandable: true description: A chat completion message generated by the model. OpenAI.ChatCompletionStreamOptions: type: object @@ -2507,6 +2172,10 @@ components: OpenAI.ChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. content: type: string nullable: true @@ -2555,7 +2224,7 @@ components: bytes: type: object allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2743,7 +2412,7 @@ components: default: vivid user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). OpenAI.CreateMessageRequest: type: object required: @@ -2822,7 +2491,7 @@ components: description: |- The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. OpenAI.FunctionObject: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml index 724e0fc2b..df7fef15d 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml @@ -82,6 +82,9 @@ paths: schema: anyOf: - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - type: array + items: + $ref: '#/components/schemas/AzureChatCompletionStreamResponseDelta' - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' tags: - Chat @@ -506,21 +509,6 @@ components: format: int32 required: - cached_tokens - AzureContentFilterBlocklistIdResult: - type: object - required: - - id - - filtered - properties: - id: - type: string - description: The ID of the custom blocklist associated with the filtered status. - filtered: - type: boolean - description: Whether the associated blocklist resulted in the content being filtered. - description: |- - A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not - the corresponding blocklist resulted in content being filtered. AzureContentFilterBlocklistResult: type: object required: @@ -545,21 +533,6 @@ components: - id description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. description: A collection of true/false filtering results for configured custom blocklists. - AzureContentFilterCompletionTextSpan: - type: object - required: - - completion_start_offset - - completion_end_offset - properties: - completion_start_offset: - type: integer - format: int32 - description: Offset of the UTF32 code point which begins the span. - completion_end_offset: - type: integer - format: int32 - description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. - description: A representation of a span of completion text as used by Azure OpenAI content filter results. AzureContentFilterDetectionResult: type: object required: @@ -632,90 +605,6 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. - AzureContentFilterResultForChoice: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - error: - type: object - properties: - code: - type: integer - format: int32 - description: A distinct, machine-readable code associated with the error. - message: - type: string - description: A human-readable message associated with the error. - required: - - code - - message - description: If present, details about an error that prevented content filtering from completing its evaluation. - protected_material_text: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: A detection result that describes a match against text protected under copyright or other status. - protected_material_code: - type: object - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - citation: - type: object - properties: - license: - type: string - description: The name or identifier of the license associated with the detection. - URL: - type: string - format: uri - description: The URL associated with the license. - description: If available, the citation details describing the associated license and its location. - required: - - filtered - - detected - description: A detection result that describes a match against licensed code or other protected source material. - description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -926,22 +815,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). + A list of messages comprising the conversation so far. Depending on the + [model](/docs/models) you use, different message types (modalities) are + supported, like [text](/docs/guides/text-generation), + [images](/docs/guides/vision), and [audio](/docs/guides/audio). frequency_penalty: type: number format: float @@ -949,9 +827,9 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + their existing frequency in the text so far, decreasing the model's + likelihood to repeat the same line verbatim. default: 0 logit_bias: type: object @@ -962,13 +840,21 @@ components: description: |- Modify the likelihood of specified tokens appearing in the completion. - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + Accepts a JSON object that maps tokens (specified by their token ID in the + tokenizer) to an associated bias value from -100 to 100. Mathematically, + the bias is added to the logits generated by the model prior to sampling. + The exact effect will vary per model, but values between -1 and 1 should + decrease or increase likelihood of selection; values like -100 or 100 + should result in a ban or exclusive selection of the relevant token. x-oaiTypeLabel: map default: null logprobs: type: boolean nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + description: |- + Whether to return log probabilities of the output tokens or not. If true, + returns the log probabilities of each output token returned in the + `content` of `message`. default: false top_logprobs: type: integer @@ -976,15 +862,21 @@ components: nullable: true minimum: 0 maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + description: |- + An integer between 0 and 20 specifying the number of most likely tokens to + return at each token position, each with an associated log probability. + `logprobs` must be set to `true` if this parameter is used. max_tokens: type: integer format: int32 nullable: true description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + The maximum number of [tokens](/tokenizer) that can be generated in the + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + This value is now deprecated in favor of `max_completion_tokens`, and is + not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true max_completion_tokens: type: integer @@ -1006,28 +898,36 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + whether they appear in the text so far, increasing the model's likelihood + to talk about new topics. default: 0 response_format: allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + An object specifying the format that the model must output. - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + **Important:** when using JSON mode, you **must** also instruct the model + to produce JSON yourself via a system or user message. Without this, the + model may generate an unending stream of whitespace until the generation + reaches the token limit, resulting in a long-running and seemingly "stuck" + request. Also note that the message content may be partially cut off if + `finish_reason="length"`, which indicates the generation exceeded + `max_tokens` or the conversation exceeded the max context length. x-oaiExpandable: true seed: type: integer format: int64 nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 description: |- This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. @@ -1060,7 +960,6 @@ components: maximum: 2 description: |- What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. default: 1 top_p: @@ -1070,7 +969,10 @@ components: minimum: 0 maximum: 1 description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + An alternative to sampling with temperature, called nucleus sampling, + where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass + are considered. We generally recommend altering this or `temperature` but not both. default: 1 @@ -1086,7 +988,7 @@ components: default: true user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). function_call: anyOf: - type: string @@ -1098,11 +1000,18 @@ components: Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - `none` is the default when no functions are present. `auto` is the default if functions are present. + `none` means the model will not call a function and instead generates a + message. + + `auto` means the model can pick between generating a message or calling a + function. + + Specifying a particular function via `{"name": "my_function"}` forces the + model to call that function. + + `none` is the default when no functions are present. `auto` is the default + if functions are present. deprecated: true x-oaiExpandable: true functions: @@ -1202,7 +1111,7 @@ components: - scale - default nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + description: The service tier used for processing the request. system_fingerprint: type: string description: |- @@ -1324,73 +1233,6 @@ components: error: $ref: '#/components/schemas/AzureOpenAIDalleError' description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIFile: - type: object - required: - - id - - bytes - - created_at - - filename - - object - - purpose - - status - properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 - nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - enum: - - file - description: The object type, which is always `file`. - purpose: - type: string - enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - status_details: - type: string - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. - deprecated: true - status: - type: string - enum: - - uploaded - - pending - - running - - processed - - error - - deleting - - deleted - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - - 2025-01-01-preview - description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object required: @@ -1528,321 +1370,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytesItem: + ChatCompletionTokenLogprobBytes: type: array items: type: integer format: int32 - CompletionUsageCommonBase: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - description: Usage statistics for the completion request. - CreateChatCompletionRequestCommonBase: - type: object - required: - - messages - properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - stop: - anyOf: - - type: string - - type: array - items: - type: string - nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean - nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true - user: - type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. - deprecated: true - x-oaiExpandable: true - functions: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - CreateChatCompletionResponseCommonBase: - type: object - required: - - id - - choices - - created - - model - - object - properties: - id: - type: string - description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: - type: string - description: The model used for the chat completion. - service_tier: - type: string - enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: - type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - enum: - - chat.completion - description: The object type, which is always `chat.completion`. - description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -2142,7 +1674,7 @@ components: description: |- The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' description: Overrides for the file search tool. @@ -2196,6 +1728,19 @@ components: parameters: $ref: '#/components/schemas/OpenAI.FunctionParameters' deprecated: true + OpenAI.ChatCompletionMessageAudioChunk: + type: object + properties: + id: + type: string + transcript: + type: string + data: + type: string + format: base64 + expires_at: + type: integer + format: unixtime OpenAI.ChatCompletionMessageToolCall: type: object required: @@ -2295,6 +1840,19 @@ components: name: type: string description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + audio: + type: object + properties: + id: + type: string + description: Unique identifier for a previous audio response from the model. + required: + - id + nullable: true + description: |- + Data about a previous audio response from the model. + [Learn more](/docs/guides/audio). + x-oaiExpandable: true tool_calls: $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: @@ -2312,6 +1870,7 @@ components: deprecated: true allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: Messages sent by the model in response to user messages. OpenAI.ChatCompletionRequestAssistantMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' @@ -2356,6 +1915,34 @@ components: tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartAudio: + type: object + required: + - type + - input_audio + properties: + type: + type: string + enum: + - input_audio + description: The type of the content part. Always `input_audio`. + input_audio: + type: object + properties: + data: + type: string + format: base64 + description: Base64 encoded audio data. + format: + type: string + enum: + - wav + - mp3 + description: The format of the encoded audio data. Currently supports "wav" and "mp3". + required: + - data + - format + description: Learn about [audio inputs](/docs/guides/audio). OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: @@ -2380,10 +1967,11 @@ components: - auto - low - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). default: auto required: - url + description: Learn about [image inputs](/docs/guides/vision). OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: @@ -2412,6 +2000,7 @@ components: text: type: string description: The text content. + description: Learn about [text inputs](/docs/guides/text-generation). OpenAI.ChatCompletionRequestSystemMessage: type: object required: @@ -2435,6 +2024,10 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. OpenAI.ChatCompletionRequestSystemMessageContentPart: type: object allOf: @@ -2493,10 +2086,14 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Messages sent by an end user, containing prompts or additional context + information. OpenAI.ChatCompletionRequestUserMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartAudio' x-oaiExpandable: true OpenAI.ChatCompletionResponseMessage: type: object @@ -2532,6 +2129,38 @@ components: - arguments description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true + audio: + type: object + properties: + id: + type: string + description: Unique identifier for this audio response. + expires_at: + type: integer + format: unixtime + description: |- + The Unix timestamp (in seconds) for when this audio response will + no longer be accessible on the server for use in multi-turn + conversations. + data: + type: string + format: base64 + description: |- + Base64 encoded audio bytes generated by the model, in the format + specified in the request. + transcript: + type: string + description: Transcript of the audio generated by the model. + required: + - id + - expires_at + - data + - transcript + nullable: true + description: |- + If the audio output modality is requested, this object contains data + about the audio response from the model. [Learn more](/docs/guides/audio). + x-oaiExpandable: true description: A chat completion message generated by the model. OpenAI.ChatCompletionStreamOptions: type: object @@ -2543,6 +2172,10 @@ components: OpenAI.ChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. content: type: string nullable: true @@ -2591,7 +2224,7 @@ components: bytes: type: object allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2779,7 +2412,7 @@ components: default: vivid user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). OpenAI.CreateMessageRequest: type: object required: @@ -2858,7 +2491,7 @@ components: description: |- The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. OpenAI.FunctionObject: type: object required: @@ -3228,52 +2861,6 @@ components: type: object additionalProperties: {} description: The schema for the response format, described as a JSON Schema object. - OpenAIFileWithOmittedProperties: - type: object - required: - - id - - bytes - - created_at - - filename - - object - - purpose - properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 - nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - enum: - - file - description: The object type, which is always `file`. - purpose: - type: string - enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - status_details: - type: string - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. - deprecated: true - description: The `File` object represents a document that has been uploaded to OpenAI. PineconeChatDataSource: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml index c334c2128..af55f023b 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml @@ -82,6 +82,9 @@ paths: schema: anyOf: - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - type: array + items: + $ref: '#/components/schemas/AzureChatCompletionStreamResponseDelta' - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' tags: - Chat @@ -506,21 +509,6 @@ components: format: int32 required: - cached_tokens - AzureContentFilterBlocklistIdResult: - type: object - required: - - id - - filtered - properties: - id: - type: string - description: The ID of the custom blocklist associated with the filtered status. - filtered: - type: boolean - description: Whether the associated blocklist resulted in the content being filtered. - description: |- - A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not - the corresponding blocklist resulted in content being filtered. AzureContentFilterBlocklistResult: type: object required: @@ -545,39 +533,6 @@ components: - id description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. description: A collection of true/false filtering results for configured custom blocklists. - AzureContentFilterCompletionTextSpan: - type: object - required: - - completion_start_offset - - completion_end_offset - properties: - completion_start_offset: - type: integer - format: int32 - description: Offset of the UTF32 code point which begins the span. - completion_end_offset: - type: integer - format: int32 - description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. - description: A representation of a span of completion text as used by Azure OpenAI content filter results. - AzureContentFilterCompletionTextSpanDetectionResult: - type: object - required: - - filtered - - detected - - details - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - details: - type: array - items: - $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' - description: Detailed information about the detected completion text spans. AzureContentFilterDetectionResult: type: object required: @@ -650,92 +605,6 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. - AzureContentFilterResultForChoice: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - error: - type: object - properties: - code: - type: integer - format: int32 - description: A distinct, machine-readable code associated with the error. - message: - type: string - description: A human-readable message associated with the error. - required: - - code - - message - description: If present, details about an error that prevented content filtering from completing its evaluation. - protected_material_text: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: A detection result that describes a match against text protected under copyright or other status. - protected_material_code: - type: object - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - citation: - type: object - properties: - license: - type: string - description: The name or identifier of the license associated with the detection. - URL: - type: string - format: uri - description: The URL associated with the license. - description: If available, the citation details describing the associated license and its location. - required: - - filtered - - detected - description: A detection result that describes a match against licensed code or other protected source material. - ungrounded_material: - $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' - description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -946,14 +815,34 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + description: |- + A list of messages comprising the conversation so far. Depending on the + [model](/docs/models) you use, different message types (modalities) are + supported, like [text](/docs/guides/text-generation), + [images](/docs/guides/vision), and [audio](/docs/guides/audio). store: type: boolean nullable: true description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + Whether or not to store the output of this chat completion request for + use in our [model distillation](/docs/guides/distillation) or + [evals](/docs/guides/evals) products. default: false + reasoning_effort: + type: string + enum: + - low + - medium + - high + description: |- + **o1 models only** + + Constrains effort on reasoning for + [reasoning models](https://platform.openai.com/docs/guides/reasoning). + Currently supported values are `low`, `medium`, and `high`. Reducing + reasoning effort can result in faster responses and fewer tokens used + on reasoning in a response. + default: medium metadata: type: object additionalProperties: @@ -969,9 +858,9 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + their existing frequency in the text so far, decreasing the model's + likelihood to repeat the same line verbatim. default: 0 logit_bias: type: object @@ -982,13 +871,21 @@ components: description: |- Modify the likelihood of specified tokens appearing in the completion. - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + Accepts a JSON object that maps tokens (specified by their token ID in the + tokenizer) to an associated bias value from -100 to 100. Mathematically, + the bias is added to the logits generated by the model prior to sampling. + The exact effect will vary per model, but values between -1 and 1 should + decrease or increase likelihood of selection; values like -100 or 100 + should result in a ban or exclusive selection of the relevant token. x-oaiTypeLabel: map default: null logprobs: type: boolean nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + description: |- + Whether to return log probabilities of the output tokens or not. If true, + returns the log probabilities of each output token returned in the + `content` of `message`. default: false top_logprobs: type: integer @@ -996,15 +893,21 @@ components: nullable: true minimum: 0 maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + description: |- + An integer between 0 and 20 specifying the number of most likely tokens to + return at each token position, each with an associated log probability. + `logprobs` must be set to `true` if this parameter is used. max_tokens: type: integer format: int32 nullable: true description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + The maximum number of [tokens](/tokenizer) that can be generated in the + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + This value is now deprecated in favor of `max_completion_tokens`, and is + not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true max_completion_tokens: type: integer @@ -1026,28 +929,36 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + whether they appear in the text so far, increasing the model's likelihood + to talk about new topics. default: 0 response_format: allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + An object specifying the format that the model must output. - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + **Important:** when using JSON mode, you **must** also instruct the model + to produce JSON yourself via a system or user message. Without this, the + model may generate an unending stream of whitespace until the generation + reaches the token limit, resulting in a long-running and seemingly "stuck" + request. Also note that the message content may be partially cut off if + `finish_reason="length"`, which indicates the generation exceeded + `max_tokens` or the conversation exceeded the max context length. x-oaiExpandable: true seed: type: integer format: int64 nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 description: |- This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. @@ -1080,7 +991,6 @@ components: maximum: 2 description: |- What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. default: 1 top_p: @@ -1090,7 +1000,10 @@ components: minimum: 0 maximum: 1 description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + An alternative to sampling with temperature, called nucleus sampling, + where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass + are considered. We generally recommend altering this or `temperature` but not both. default: 1 @@ -1106,7 +1019,7 @@ components: default: true user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). function_call: anyOf: - type: string @@ -1118,11 +1031,18 @@ components: Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - `none` is the default when no functions are present. `auto` is the default if functions are present. + `none` means the model will not call a function and instead generates a + message. + + `auto` means the model can pick between generating a message or calling a + function. + + Specifying a particular function via `{"name": "my_function"}` forces the + model to call that function. + + `none` is the default when no functions are present. `auto` is the default + if functions are present. deprecated: true x-oaiExpandable: true functions: @@ -1224,7 +1144,7 @@ components: - scale - default nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + description: The service tier used for processing the request. system_fingerprint: type: string description: |- @@ -1346,73 +1266,6 @@ components: error: $ref: '#/components/schemas/AzureOpenAIDalleError' description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIFile: - type: object - required: - - id - - bytes - - created_at - - filename - - object - - purpose - - status - properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 - nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - enum: - - file - description: The object type, which is always `file`. - purpose: - type: string - enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - status_details: - type: string - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. - deprecated: true - status: - type: string - enum: - - uploaded - - pending - - running - - processed - - error - - deleting - - deleted - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - - 2025-01-01-preview - description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object required: @@ -1566,321 +1419,11 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytesItem: + ChatCompletionTokenLogprobBytes: type: array items: type: integer format: int32 - CompletionUsageCommonBase: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - description: Usage statistics for the completion request. - CreateChatCompletionRequestCommonBase: - type: object - required: - - messages - properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - stop: - anyOf: - - type: string - - type: array - items: - type: string - nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean - nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true - user: - type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. - deprecated: true - x-oaiExpandable: true - functions: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - CreateChatCompletionResponseCommonBase: - type: object - required: - - id - - choices - - created - - model - - object - properties: - id: - type: string - description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: - type: string - description: The model used for the chat completion. - service_tier: - type: string - enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: - type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - enum: - - chat.completion - description: The object type, which is always `chat.completion`. - description: Represents a chat completion response returned by model, based on the provided input. CreateMessageRequestAttachments: type: array items: @@ -2180,7 +1723,7 @@ components: description: |- The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' description: Overrides for the file search tool. @@ -2234,6 +1777,19 @@ components: parameters: $ref: '#/components/schemas/OpenAI.FunctionParameters' deprecated: true + OpenAI.ChatCompletionMessageAudioChunk: + type: object + properties: + id: + type: string + transcript: + type: string + data: + type: string + format: base64 + expires_at: + type: integer + format: unixtime OpenAI.ChatCompletionMessageToolCall: type: object required: @@ -2333,6 +1889,19 @@ components: name: type: string description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + audio: + type: object + properties: + id: + type: string + description: Unique identifier for a previous audio response from the model. + required: + - id + nullable: true + description: |- + Data about a previous audio response from the model. + [Learn more](/docs/guides/audio). + x-oaiExpandable: true tool_calls: $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: @@ -2350,11 +1919,39 @@ components: deprecated: true allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: Messages sent by the model in response to user messages. OpenAI.ChatCompletionRequestAssistantMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' x-oaiExpandable: true + OpenAI.ChatCompletionRequestDeveloperMessage: + type: object + required: + - content + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + description: The contents of the developer message. + role: + type: string + enum: + - developer + description: The role of the messages author, in this case `developer`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, `developer` messages + replace the previous `system` messages. OpenAI.ChatCompletionRequestFunctionMessage: type: object required: @@ -2389,11 +1986,40 @@ components: propertyName: role mapping: system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + developer: '#/components/schemas/OpenAI.ChatCompletionRequestDeveloperMessage' user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartAudio: + type: object + required: + - type + - input_audio + properties: + type: + type: string + enum: + - input_audio + description: The type of the content part. Always `input_audio`. + input_audio: + type: object + properties: + data: + type: string + format: base64 + description: Base64 encoded audio data. + format: + type: string + enum: + - wav + - mp3 + description: The format of the encoded audio data. Currently supports "wav" and "mp3". + required: + - data + - format + description: Learn about [audio inputs](/docs/guides/audio). OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: @@ -2418,10 +2044,11 @@ components: - auto - low - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). default: auto required: - url + description: Learn about [image inputs](/docs/guides/vision). OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: @@ -2450,6 +2077,7 @@ components: text: type: string description: The text content. + description: Learn about [text inputs](/docs/guides/text-generation). OpenAI.ChatCompletionRequestSystemMessage: type: object required: @@ -2473,6 +2101,10 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. OpenAI.ChatCompletionRequestSystemMessageContentPart: type: object allOf: @@ -2531,10 +2163,14 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Messages sent by an end user, containing prompts or additional context + information. OpenAI.ChatCompletionRequestUserMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartAudio' x-oaiExpandable: true OpenAI.ChatCompletionResponseMessage: type: object @@ -2570,6 +2206,38 @@ components: - arguments description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true + audio: + type: object + properties: + id: + type: string + description: Unique identifier for this audio response. + expires_at: + type: integer + format: unixtime + description: |- + The Unix timestamp (in seconds) for when this audio response will + no longer be accessible on the server for use in multi-turn + conversations. + data: + type: string + format: base64 + description: |- + Base64 encoded audio bytes generated by the model, in the format + specified in the request. + transcript: + type: string + description: Transcript of the audio generated by the model. + required: + - id + - expires_at + - data + - transcript + nullable: true + description: |- + If the audio output modality is requested, this object contains data + about the audio response from the model. [Learn more](/docs/guides/audio). + x-oaiExpandable: true description: A chat completion message generated by the model. OpenAI.ChatCompletionStreamOptions: type: object @@ -2581,6 +2249,10 @@ components: OpenAI.ChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. content: type: string nullable: true @@ -2629,7 +2301,7 @@ components: bytes: type: object allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2817,7 +2489,7 @@ components: default: vivid user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). OpenAI.CreateMessageRequest: type: object required: @@ -2896,7 +2568,7 @@ components: description: |- The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. OpenAI.FunctionObject: type: object required: @@ -3266,52 +2938,6 @@ components: type: object additionalProperties: {} description: The schema for the response format, described as a JSON Schema object. - OpenAIFileWithOmittedProperties: - type: object - required: - - id - - bytes - - created_at - - filename - - object - - purpose - properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 - nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - enum: - - file - description: The object type, which is always `file`. - purpose: - type: string - enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - status_details: - type: string - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. - deprecated: true - description: The `File` object represents a document that has been uploaded to OpenAI. PineconeChatDataSource: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml index 14ae18651..e3024692a 100644 --- a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml @@ -82,6 +82,9 @@ paths: schema: anyOf: - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' + - type: array + items: + $ref: '#/components/schemas/AzureChatCompletionStreamResponseDelta' - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' tags: - Chat @@ -506,21 +509,6 @@ components: format: int32 required: - cached_tokens - AzureContentFilterBlocklistIdResult: - type: object - required: - - id - - filtered - properties: - id: - type: string - description: The ID of the custom blocklist associated with the filtered status. - filtered: - type: boolean - description: Whether the associated blocklist resulted in the content being filtered. - description: |- - A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not - the corresponding blocklist resulted in content being filtered. AzureContentFilterBlocklistResult: type: object required: @@ -545,39 +533,6 @@ components: - id description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. description: A collection of true/false filtering results for configured custom blocklists. - AzureContentFilterCompletionTextSpan: - type: object - required: - - completion_start_offset - - completion_end_offset - properties: - completion_start_offset: - type: integer - format: int32 - description: Offset of the UTF32 code point which begins the span. - completion_end_offset: - type: integer - format: int32 - description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. - description: A representation of a span of completion text as used by Azure OpenAI content filter results. - AzureContentFilterCompletionTextSpanDetectionResult: - type: object - required: - - filtered - - detected - - details - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - details: - type: array - items: - $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' - description: Detailed information about the detected completion text spans. AzureContentFilterDetectionResult: type: object required: @@ -650,92 +605,6 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. - AzureContentFilterResultForChoice: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - error: - type: object - properties: - code: - type: integer - format: int32 - description: A distinct, machine-readable code associated with the error. - message: - type: string - description: A human-readable message associated with the error. - required: - - code - - message - description: If present, details about an error that prevented content filtering from completing its evaluation. - protected_material_text: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: A detection result that describes a match against text protected under copyright or other status. - protected_material_code: - type: object - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - citation: - type: object - properties: - license: - type: string - description: The name or identifier of the license associated with the detection. - URL: - type: string - format: uri - description: The URL associated with the license. - description: If available, the citation details describing the associated license and its location. - required: - - filtered - - detected - description: A detection result that describes a match against licensed code or other protected source material. - ungrounded_material: - $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' - description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -946,14 +815,34 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. + description: |- + A list of messages comprising the conversation so far. Depending on the + [model](/docs/models) you use, different message types (modalities) are + supported, like [text](/docs/guides/text-generation), + [images](/docs/guides/vision), and [audio](/docs/guides/audio). store: type: boolean nullable: true description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + Whether or not to store the output of this chat completion request for + use in our [model distillation](/docs/guides/distillation) or + [evals](/docs/guides/evals) products. default: false + reasoning_effort: + type: string + enum: + - low + - medium + - high + description: |- + **o1 models only** + + Constrains effort on reasoning for + [reasoning models](https://platform.openai.com/docs/guides/reasoning). + Currently supported values are `low`, `medium`, and `high`. Reducing + reasoning effort can result in faster responses and fewer tokens used + on reasoning in a response. + default: medium metadata: type: object additionalProperties: @@ -969,9 +858,9 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + their existing frequency in the text so far, decreasing the model's + likelihood to repeat the same line verbatim. default: 0 logit_bias: type: object @@ -982,13 +871,21 @@ components: description: |- Modify the likelihood of specified tokens appearing in the completion. - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + Accepts a JSON object that maps tokens (specified by their token ID in the + tokenizer) to an associated bias value from -100 to 100. Mathematically, + the bias is added to the logits generated by the model prior to sampling. + The exact effect will vary per model, but values between -1 and 1 should + decrease or increase likelihood of selection; values like -100 or 100 + should result in a ban or exclusive selection of the relevant token. x-oaiTypeLabel: map default: null logprobs: type: boolean nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + description: |- + Whether to return log probabilities of the output tokens or not. If true, + returns the log probabilities of each output token returned in the + `content` of `message`. default: false top_logprobs: type: integer @@ -996,15 +893,21 @@ components: nullable: true minimum: 0 maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. + description: |- + An integer between 0 and 20 specifying the number of most likely tokens to + return at each token position, each with an associated log probability. + `logprobs` must be set to `true` if this parameter is used. max_tokens: type: integer format: int32 nullable: true description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + The maximum number of [tokens](/tokenizer) that can be generated in the + chat completion. This value can be used to control + [costs](https://openai.com/api/pricing/) for text generated via API. - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + This value is now deprecated in favor of `max_completion_tokens`, and is + not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true max_completion_tokens: type: integer @@ -1019,6 +922,56 @@ components: maximum: 128 description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. default: 1 + modalities: + type: object + allOf: + - $ref: '#/components/schemas/ChatCompletionModalities' + nullable: true + prediction: + type: object + allOf: + - $ref: '#/components/schemas/OpenAI.PredictionContent' + nullable: true + description: |- + Configuration for a [Predicted Output](/docs/guides/predicted-outputs), + which can greatly improve response times when large parts of the model + response are known ahead of time. This is most common when you are + regenerating a file with only minor changes to most of the content. + x-oaiExpandable: true + audio: + type: object + properties: + voice: + type: string + enum: + - alloy + - ash + - ballad + - coral + - echo + - sage + - shimmer + - verse + description: The voice the model uses to respond. Supported voices are `ash`, `ballad`, `coral`, `sage`, and `verse` (also supported but not recommended are `alloy`, `echo`, and `shimmer`; these voices are less expressive). + format: + type: string + enum: + - wav + - mp3 + - flac + - opus + - pcm16 + description: |- + Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, + `opus`, or `pcm16`. + required: + - voice + - format + nullable: true + description: |- + Parameters for audio output. Required when audio output is requested with + `modalities: ["audio"]`. [Learn more](/docs/guides/audio). + x-oaiExpandable: true presence_penalty: type: number format: float @@ -1026,28 +979,36 @@ components: minimum: -2 maximum: 2 description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + Number between -2.0 and 2.0. Positive values penalize new tokens based on + whether they appear in the text so far, increasing the model's likelihood + to talk about new topics. default: 0 response_format: allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + An object specifying the format that the model must output. - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + **Important:** when using JSON mode, you **must** also instruct the model + to produce JSON yourself via a system or user message. Without this, the + model may generate an unending stream of whitespace until the generation + reaches the token limit, resulting in a long-running and seemingly "stuck" + request. Also note that the message content may be partially cut off if + `finish_reason="length"`, which indicates the generation exceeded + `max_tokens` or the conversation exceeded the max context length. x-oaiExpandable: true seed: type: integer format: int64 nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 description: |- This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. @@ -1080,7 +1041,6 @@ components: maximum: 2 description: |- What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or `top_p` but not both. default: 1 top_p: @@ -1090,7 +1050,10 @@ components: minimum: 0 maximum: 1 description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + An alternative to sampling with temperature, called nucleus sampling, + where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass + are considered. We generally recommend altering this or `temperature` but not both. default: 1 @@ -1106,7 +1069,7 @@ components: default: true user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). function_call: anyOf: - type: string @@ -1118,11 +1081,18 @@ components: Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - `none` is the default when no functions are present. `auto` is the default if functions are present. + `none` means the model will not call a function and instead generates a + message. + + `auto` means the model can pick between generating a message or calling a + function. + + Specifying a particular function via `{"name": "my_function"}` forces the + model to call that function. + + `none` is the default when no functions are present. `auto` is the default + if functions are present. deprecated: true x-oaiExpandable: true functions: @@ -1224,7 +1194,7 @@ components: - scale - default nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + description: The service tier used for processing the request. system_fingerprint: type: string description: |- @@ -1346,73 +1316,6 @@ components: error: $ref: '#/components/schemas/AzureOpenAIDalleError' description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIFile: - type: object - required: - - id - - bytes - - created_at - - filename - - object - - purpose - - status - properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 - nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - enum: - - file - description: The object type, which is always `file`. - purpose: - type: string - enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - status_details: - type: string - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. - deprecated: true - status: - type: string - enum: - - uploaded - - pending - - running - - processed - - error - - deleting - - deleted - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - - 2025-01-01-preview - description: Known service API versions for Azure OpenAI. AzureSearchChatDataSource: type: object required: @@ -1517,370 +1420,78 @@ components: query_type: type: string enum: - - simple - - semantic - - vector - - vector_simple_hybrid - - vector_semantic_hybrid - description: The query type for the Azure Search resource to use. - semantic_configuration: - type: string - description: Additional semantic configuration for the query. - filter: - type: string - description: A filter to apply to the search. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' - description: |- - The vectorization source to use with Azure Search. - Supported sources for Azure Search include endpoint, deployment name, and integrated. - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Azure Search data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Search resource. - AzureUserSecurityContext: - type: object - properties: - application_name: - type: string - description: The name of the application. Sensitive personal information should not be included in this field. - end_user_id: - type: string - description: This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. - end_user_tenant_id: - type: string - description: The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. - source_ip: - type: string - description: Captures the original client's IP address. - description: User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. - ChatCompletionMessageToolCallsItem: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' - description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytesItem: - type: array - items: - type: integer - format: int32 - CompletionUsageCommonBase: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - description: Usage statistics for the completion request. - CreateChatCompletionRequestCommonBase: - type: object - required: - - messages - properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - stop: - anyOf: - - type: string - - type: array - items: - type: string - nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean - nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true - user: - type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. - deprecated: true - x-oaiExpandable: true - functions: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - CreateChatCompletionResponseCommonBase: + - simple + - semantic + - vector + - vector_simple_hybrid + - vector_semantic_hybrid + description: The query type for the Azure Search resource to use. + semantic_configuration: + type: string + description: Additional semantic configuration for the query. + filter: + type: string + description: A filter to apply to the search. + embedding_dependency: + anyOf: + - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + description: |- + The vectorization source to use with Azure Search. + Supported sources for Azure Search include endpoint, deployment name, and integrated. + required: + - endpoint + - index_name + - authentication + description: The parameter information to control the use of the Azure Search data source. + allOf: + - $ref: '#/components/schemas/AzureChatDataSource' + description: Represents a data source configuration that will use an Azure Search resource. + AzureUserSecurityContext: type: object - required: - - id - - choices - - created - - model - - object properties: - id: + application_name: type: string - description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: + description: The name of the application. Sensitive personal information should not be included in this field. + end_user_id: type: string - description: The model used for the chat completion. - service_tier: + description: This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. + end_user_tenant_id: type: string - enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: + description: The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. + source_ip: type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. + description: Captures the original client's IP address. + description: User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. + ChatCompletionMessageToolCallsItem: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' + description: The tool calls generated by the model, such as function calls. + ChatCompletionModalities: + type: array + items: + type: string + enum: + - text + - audio + description: |- + Output types that you would like the model to generate for this request. + Most models are capable of generating text, which is the default: - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - enum: - - chat.completion - description: The object type, which is always `chat.completion`. - description: Represents a chat completion response returned by model, based on the provided input. + `["text"]` + + The `gpt-4o-audio-preview` model can also be used to [generate audio](/docs/guides/audio). To + request that this model generate both text and audio responses, you can + use: + + `["text", "audio"]` + ChatCompletionTokenLogprobBytes: + type: array + items: + type: integer + format: int32 CreateMessageRequestAttachments: type: array items: @@ -2180,7 +1791,7 @@ components: description: |- The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ranking_options: $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' description: Overrides for the file search tool. @@ -2234,6 +1845,19 @@ components: parameters: $ref: '#/components/schemas/OpenAI.FunctionParameters' deprecated: true + OpenAI.ChatCompletionMessageAudioChunk: + type: object + properties: + id: + type: string + transcript: + type: string + data: + type: string + format: base64 + expires_at: + type: integer + format: unixtime OpenAI.ChatCompletionMessageToolCall: type: object required: @@ -2333,6 +1957,19 @@ components: name: type: string description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + audio: + type: object + properties: + id: + type: string + description: Unique identifier for a previous audio response from the model. + required: + - id + nullable: true + description: |- + Data about a previous audio response from the model. + [Learn more](/docs/guides/audio). + x-oaiExpandable: true tool_calls: $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' function_call: @@ -2350,11 +1987,39 @@ components: deprecated: true allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: Messages sent by the model in response to user messages. OpenAI.ChatCompletionRequestAssistantMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' x-oaiExpandable: true + OpenAI.ChatCompletionRequestDeveloperMessage: + type: object + required: + - content + - role + properties: + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + description: The contents of the developer message. + role: + type: string + enum: + - developer + description: The role of the messages author, in this case `developer`. + name: + type: string + description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, `developer` messages + replace the previous `system` messages. OpenAI.ChatCompletionRequestFunctionMessage: type: object required: @@ -2389,11 +2054,40 @@ components: propertyName: role mapping: system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' + developer: '#/components/schemas/OpenAI.ChatCompletionRequestDeveloperMessage' user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' x-oaiExpandable: true + OpenAI.ChatCompletionRequestMessageContentPartAudio: + type: object + required: + - type + - input_audio + properties: + type: + type: string + enum: + - input_audio + description: The type of the content part. Always `input_audio`. + input_audio: + type: object + properties: + data: + type: string + format: base64 + description: Base64 encoded audio data. + format: + type: string + enum: + - wav + - mp3 + description: The format of the encoded audio data. Currently supports "wav" and "mp3". + required: + - data + - format + description: Learn about [audio inputs](/docs/guides/audio). OpenAI.ChatCompletionRequestMessageContentPartImage: type: object required: @@ -2418,10 +2112,11 @@ components: - auto - low - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision#low-or-high-fidelity-image-understanding). default: auto required: - url + description: Learn about [image inputs](/docs/guides/vision). OpenAI.ChatCompletionRequestMessageContentPartRefusal: type: object required: @@ -2450,6 +2145,7 @@ components: text: type: string description: The text content. + description: Learn about [text inputs](/docs/guides/text-generation). OpenAI.ChatCompletionRequestSystemMessage: type: object required: @@ -2473,6 +2169,10 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. OpenAI.ChatCompletionRequestSystemMessageContentPart: type: object allOf: @@ -2531,10 +2231,14 @@ components: description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' + description: |- + Messages sent by an end user, containing prompts or additional context + information. OpenAI.ChatCompletionRequestUserMessageContentPart: anyOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' + - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartAudio' x-oaiExpandable: true OpenAI.ChatCompletionResponseMessage: type: object @@ -2570,6 +2274,38 @@ components: - arguments description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. deprecated: true + audio: + type: object + properties: + id: + type: string + description: Unique identifier for this audio response. + expires_at: + type: integer + format: unixtime + description: |- + The Unix timestamp (in seconds) for when this audio response will + no longer be accessible on the server for use in multi-turn + conversations. + data: + type: string + format: base64 + description: |- + Base64 encoded audio bytes generated by the model, in the format + specified in the request. + transcript: + type: string + description: Transcript of the audio generated by the model. + required: + - id + - expires_at + - data + - transcript + nullable: true + description: |- + If the audio output modality is requested, this object contains data + about the audio response from the model. [Learn more](/docs/guides/audio). + x-oaiExpandable: true description: A chat completion message generated by the model. OpenAI.ChatCompletionStreamOptions: type: object @@ -2581,6 +2317,10 @@ components: OpenAI.ChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. content: type: string nullable: true @@ -2629,7 +2369,7 @@ components: bytes: type: object allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2817,7 +2557,7 @@ components: default: vivid user: type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). OpenAI.CreateMessageRequest: type: object required: @@ -2896,7 +2636,7 @@ components: description: |- The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. OpenAI.FunctionObject: type: object required: @@ -3262,56 +3002,37 @@ components: allOf: - $ref: '#/components/schemas/OpenAI.MessageContent' description: The text content that is part of a message. - OpenAI.ResponseFormatJsonSchemaSchema: - type: object - additionalProperties: {} - description: The schema for the response format, described as a JSON Schema object. - OpenAIFileWithOmittedProperties: + OpenAI.PredictionContent: type: object required: - - id - - bytes - - created_at - - filename - - object - - purpose + - type + - content properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 - nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - enum: - - file - description: The object type, which is always `file`. - purpose: + type: type: string enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - status_details: - type: string - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. - deprecated: true - description: The `File` object represents a document that has been uploaded to OpenAI. + - content + description: |- + The type of the predicted content you want to provide. This type is + currently always `content`. + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + description: |- + The content that should be matched when generating a model response. + If generated tokens would match this content, the entire model response + can be returned much more quickly. + x-oaiExpandable: true + description: |- + Static predicted output content, such as the content of a text file that is + being regenerated. + OpenAI.ResponseFormatJsonSchemaSchema: + type: object + additionalProperties: {} + description: The schema for the response format, described as a JSON Schema object. PineconeChatDataSource: type: object required: diff --git a/.typespec.azure/chat/models.request.tsp b/.typespec.azure/chat/models.request.tsp index 31ee40aee..8a6fcaaba 100644 --- a/.typespec.azure/chat/models.request.tsp +++ b/.typespec.azure/chat/models.request.tsp @@ -14,6 +14,29 @@ namespace AzureOpenAI; model CreateChatCompletionRequestCommonBase is OpenAI.CreateChatCompletionRequest; +@@added(CreateChatCompletionRequestCommonBase.modalities, + AzureOpenAIServiceApiVersion.v2025_01_01_preview +); +@@added(CreateChatCompletionRequestCommonBase.prediction, + AzureOpenAIServiceApiVersion.v2025_01_01_preview +); +@@added(CreateChatCompletionRequestCommonBase.audio, + AzureOpenAIServiceApiVersion.v2025_01_01_preview +); + +@@added(CreateChatCompletionRequestCommonBase.store, + AzureOpenAIServiceApiVersion.v2024_12_01_preview +); +@@added(CreateChatCompletionRequestCommonBase.metadata, + AzureOpenAIServiceApiVersion.v2024_12_01_preview +); +@@added(CreateChatCompletionRequestCommonBase.reasoning_effort, + AzureOpenAIServiceApiVersion.v2024_12_01_preview +); +@@added(OpenAI.ChatCompletionRequestDeveloperMessage, + AzureOpenAIServiceApiVersion.v2024_12_01_preview +); + /** * The extended request model for chat completions against the Azure OpenAI service. * This adds the ability to provide data sources for the On Your Data feature. diff --git a/.typespec.azure/chat/operations.tsp b/.typespec.azure/chat/operations.tsp index 0fafc04f7..7c79511c7 100644 --- a/.typespec.azure/chat/operations.tsp +++ b/.typespec.azure/chat/operations.tsp @@ -20,5 +20,5 @@ interface AzureChat { createChatCompletion( @path deployment_id: string, @body request: AzureCreateChatCompletionRequest, - ): AzureCreateChatCompletionResponse | AzureOpenAIChatErrorResponse; + ): AzureCreateChatCompletionResponse | AzureChatCompletionStreamResponseDelta[] | AzureOpenAIChatErrorResponse; } diff --git a/.typespec.azure/tspconfig.yaml b/.typespec.azure/tspconfig.yaml index d6a1bc0f8..9adc4a453 100644 --- a/.typespec.azure/tspconfig.yaml +++ b/.typespec.azure/tspconfig.yaml @@ -4,6 +4,7 @@ emit: options: "@typespec/openapi3": output-file: "{project-root}/../.openapi3.azure/openapi3-azure-openai-{version}-generated.yaml" + omit-unreachable-types: true "@azure-tools/typespec-csharp": namespace: "Azure.AI.OpenAI" emitter-output-dir: "{project-root}/../.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src" From b87dfad90ed2f83fb69ab2a9ea21f14ed1d2c1a3 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 22 Jan 2025 16:28:34 -0800 Subject: [PATCH 22/44] a few more spec accuracy updates (also no code change) --- ...pi3-azure-openai-2024-06-01-generated.yaml | 58 +------------------ ...e-openai-2024-08-01-preview-generated.yaml | 21 ------- .typespec.azure/chat/models.request.tsp | 40 +++++++++++++ 3 files changed, 42 insertions(+), 77 deletions(-) diff --git a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml index 1761788ab..801a4e8c3 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml @@ -852,11 +852,6 @@ components: This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). n: type: integer format: int32 @@ -920,12 +915,6 @@ components: nullable: true description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null temperature: type: number format: float @@ -957,9 +946,6 @@ components: description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. tool_choice: $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true user: type: string description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). @@ -1772,12 +1758,7 @@ components: - role properties: content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessageContentPart' - nullable: true + type: string description: The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. x-oaiExpandable: true refusal: @@ -1823,11 +1804,6 @@ components: allOf: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' description: Messages sent by the model in response to user messages. - OpenAI.ChatCompletionRequestAssistantMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' - x-oaiExpandable: true OpenAI.ChatCompletionRequestFunctionMessage: type: object required: @@ -1924,20 +1900,6 @@ components: required: - url description: Learn about [image inputs](/docs/guides/vision). - OpenAI.ChatCompletionRequestMessageContentPartRefusal: - type: object - required: - - type - - refusal - properties: - type: - type: string - enum: - - refusal - description: The type of the content part. - refusal: - type: string - description: The refusal message generated by the model. OpenAI.ChatCompletionRequestMessageContentPartText: type: object required: @@ -1960,11 +1922,7 @@ components: - role properties: content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' + type: string description: The contents of the system message. role: type: string @@ -1980,11 +1938,6 @@ components: Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, use `developer` messages for this purpose instead. - OpenAI.ChatCompletionRequestSystemMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true OpenAI.ChatCompletionRequestToolMessage: type: object required: @@ -2114,13 +2067,6 @@ components: about the audio response from the model. [Learn more](/docs/guides/audio). x-oaiExpandable: true description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamOptions: - type: object - properties: - include_usage: - type: boolean - description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' - description: 'Options for streaming response. Only set this when you set `stream: true`.' OpenAI.ChatCompletionStreamResponseDelta: type: object properties: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml index 2805ab4ae..0e020ecce 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml @@ -878,11 +878,6 @@ components: This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). n: type: integer format: int32 @@ -946,12 +941,6 @@ components: nullable: true description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null temperature: type: number format: float @@ -983,9 +972,6 @@ components: description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. tool_choice: $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true user: type: string description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). @@ -2162,13 +2148,6 @@ components: about the audio response from the model. [Learn more](/docs/guides/audio). x-oaiExpandable: true description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamOptions: - type: object - properties: - include_usage: - type: boolean - description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' - description: 'Options for streaming response. Only set this when you set `stream: true`.' OpenAI.ChatCompletionStreamResponseDelta: type: object properties: diff --git a/.typespec.azure/chat/models.request.tsp b/.typespec.azure/chat/models.request.tsp index 8a6fcaaba..c154b9eec 100644 --- a/.typespec.azure/chat/models.request.tsp +++ b/.typespec.azure/chat/models.request.tsp @@ -14,6 +14,8 @@ namespace AzureOpenAI; model CreateChatCompletionRequestCommonBase is OpenAI.CreateChatCompletionRequest; +// Ingested changes from OpenAI for 2025-01-01-preview + @@added(CreateChatCompletionRequestCommonBase.modalities, AzureOpenAIServiceApiVersion.v2025_01_01_preview ); @@ -24,6 +26,8 @@ model CreateChatCompletionRequestCommonBase AzureOpenAIServiceApiVersion.v2025_01_01_preview ); +// Ingested changes from OpenAI for 2024-12-01-preview + @@added(CreateChatCompletionRequestCommonBase.store, AzureOpenAIServiceApiVersion.v2024_12_01_preview ); @@ -37,6 +41,42 @@ model CreateChatCompletionRequestCommonBase AzureOpenAIServiceApiVersion.v2024_12_01_preview ); +// Ingested changes from OpenAI for 2024-10-01-preview + +@@added(OpenAI.CompletionUsage.prompt_tokens_details, + AzureOpenAIServiceApiVersion.v2024_10_01_preview +); + +// Ingested changes from OpenAI for 2024-09-01-preview + +@@added(CreateChatCompletionRequestCommonBase.stream_options, + AzureOpenAIServiceApiVersion.v2024_09_01_preview +); +@@added(CreateChatCompletionRequestCommonBase.max_completion_tokens, + AzureOpenAIServiceApiVersion.v2024_09_01_preview +); +@@added(CreateChatCompletionRequestCommonBase.parallel_tool_calls, + AzureOpenAIServiceApiVersion.v2024_09_01_preview +); +@@added(OpenAI.CompletionUsage.completion_tokens_details, + AzureOpenAIServiceApiVersion.v2024_09_01_preview +); + +// Ingested changes from OpenAI for 2024-08-01-preview + +@@typeChangedFrom(OpenAI.ChatCompletionRequestSystemMessage.content, + AzureOpenAIServiceApiVersion.v2024_08_01_preview, + string +); +@@typeChangedFrom(OpenAI.ChatCompletionRequestAssistantMessage.content, + AzureOpenAIServiceApiVersion.v2024_08_01_preview, + string +); + +// Ingested changes from OpenAI for 2024-07-01-preview + +// @@added(OpenAI.ChatCompletionToolChoiceOption.required, AzureOpenAIServiceApiVersion.v2024_07_01_preview); + /** * The extended request model for chat completions against the Azure OpenAI service. * This adds the ability to provide data sources for the On Your Data feature. From 6f3998c58822f872266b0ddc65e9eb15ece18781 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 22 Jan 2025 16:59:34 -0800 Subject: [PATCH 23/44] a few more spec accuracy updates (also no code change) --- ...pi3-azure-openai-2024-06-01-generated.yaml | 145 +++++--------- ...e-openai-2024-08-01-preview-generated.yaml | 145 +++++--------- ...e-openai-2024-09-01-preview-generated.yaml | 172 ++++++++-------- ...e-openai-2024-10-01-preview-generated.yaml | 184 +++++++++--------- ...pi3-azure-openai-2024-10-21-generated.yaml | 184 +++++++++--------- ...e-openai-2024-12-01-preview-generated.yaml | 184 +++++++++--------- ...e-openai-2025-01-01-preview-generated.yaml | 184 +++++++++--------- .typespec.azure/chat/models.response.tsp | 31 +-- 8 files changed, 568 insertions(+), 661 deletions(-) diff --git a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml index 801a4e8c3..df85f1fe0 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml @@ -100,28 +100,46 @@ security: - https://cognitiveservices.azure.com/.default components: schemas: - AzureChatCompletionResponseMessage: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - description: |- - The extended response model component for chat completion response messages on the Azure OpenAI service. - This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other - information related to retrieval-augmented generation performed. AzureChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. context: allOf: - $ref: '#/components/schemas/AzureChatMessageContext' description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' description: |- The extended response model for a streaming chat response message on the Azure OpenAI service. This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other @@ -440,43 +458,6 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. - AzureCompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - - completion_tokens_details - - prompt_tokens_details - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - reasoning_tokens: - type: integer - format: int32 - required: - - reasoning_tokens - prompt_tokens_details: - type: object - properties: - cached_tokens: - type: integer - format: int32 - required: - - cached_tokens AzureContentFilterBlocklistResult: type: object required: @@ -1001,7 +982,6 @@ components: - created - model - object - - usage properties: id: type: string @@ -1084,7 +1064,7 @@ components: - chat.completion description: The object type, which is always `chat.completion`. usage: - $ref: '#/components/schemas/AzureCompletionUsage' + $ref: '#/components/schemas/OpenAI.CompletionUsage' prompt_filter_results: type: array items: @@ -2067,43 +2047,6 @@ components: about the audio response from the model. [Learn more](/docs/guides/audio). x-oaiExpandable: true description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - audio: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' - description: Response audio associated with the streaming chat delta payload. - content: - type: string - nullable: true - description: The contents of the chunk message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. OpenAI.ChatCompletionTokenLogprob: type: object required: @@ -2247,6 +2190,26 @@ components: description: 'The type of response format being defined: `text`' allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + description: Usage statistics for the completion request. OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml index 0e020ecce..c08ffa725 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml @@ -100,28 +100,46 @@ security: - https://cognitiveservices.azure.com/.default components: schemas: - AzureChatCompletionResponseMessage: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - description: |- - The extended response model component for chat completion response messages on the Azure OpenAI service. - This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other - information related to retrieval-augmented generation performed. AzureChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. context: allOf: - $ref: '#/components/schemas/AzureChatMessageContext' description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' description: |- The extended response model for a streaming chat response message on the Azure OpenAI service. This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other @@ -472,43 +490,6 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. - AzureCompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - - completion_tokens_details - - prompt_tokens_details - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - reasoning_tokens: - type: integer - format: int32 - required: - - reasoning_tokens - prompt_tokens_details: - type: object - properties: - cached_tokens: - type: integer - format: int32 - required: - - cached_tokens AzureContentFilterBlocklistResult: type: object required: @@ -1027,7 +1008,6 @@ components: - created - model - object - - usage properties: id: type: string @@ -1110,7 +1090,7 @@ components: - chat.completion description: The object type, which is always `chat.completion`. usage: - $ref: '#/components/schemas/AzureCompletionUsage' + $ref: '#/components/schemas/OpenAI.CompletionUsage' prompt_filter_results: type: array items: @@ -2148,43 +2128,6 @@ components: about the audio response from the model. [Learn more](/docs/guides/audio). x-oaiExpandable: true description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - audio: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' - description: Response audio associated with the streaming chat delta payload. - content: - type: string - nullable: true - description: The contents of the chunk message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. OpenAI.ChatCompletionTokenLogprob: type: object required: @@ -2328,6 +2271,26 @@ components: description: 'The type of response format being defined: `text`' allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + description: Usage statistics for the completion request. OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml index fc2a322ca..e03b8b347 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml @@ -100,28 +100,46 @@ security: - https://cognitiveservices.azure.com/.default components: schemas: - AzureChatCompletionResponseMessage: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - description: |- - The extended response model component for chat completion response messages on the Azure OpenAI service. - This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other - information related to retrieval-augmented generation performed. AzureChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. context: allOf: - $ref: '#/components/schemas/AzureChatMessageContext' description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' description: |- The extended response model for a streaming chat response message on the Azure OpenAI service. This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other @@ -472,43 +490,6 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. - AzureCompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - - completion_tokens_details - - prompt_tokens_details - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - reasoning_tokens: - type: integer - format: int32 - required: - - reasoning_tokens - prompt_tokens_details: - type: object - properties: - cached_tokens: - type: integer - format: int32 - required: - - cached_tokens AzureContentFilterBlocklistResult: type: object required: @@ -1041,7 +1022,6 @@ components: - created - model - object - - usage properties: id: type: string @@ -1124,7 +1104,7 @@ components: - chat.completion description: The object type, which is always `chat.completion`. usage: - $ref: '#/components/schemas/AzureCompletionUsage' + $ref: '#/components/schemas/OpenAI.CompletionUsage' prompt_filter_results: type: array items: @@ -2169,43 +2149,6 @@ components: type: boolean description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - audio: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' - description: Response audio associated with the streaming chat delta payload. - content: - type: string - nullable: true - description: The contents of the chunk message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. OpenAI.ChatCompletionTokenLogprob: type: object required: @@ -2349,6 +2292,53 @@ components: description: 'The type of response format being defined: `text`' allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + accepted_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that appeared in the completion. + audio_tokens: + type: integer + format: int32 + description: Audio input tokens generated by the model. + reasoning_tokens: + type: integer + format: int32 + description: Tokens generated by the model for reasoning. + rejected_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that did not appear in the completion. However, like + reasoning tokens, these tokens are still counted in the total + completion tokens for purposes of billing, output, and context window + limits. + description: Breakdown of tokens used in a completion. + description: Usage statistics for the completion request. OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml index 78400d623..5a91a3487 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml @@ -100,28 +100,46 @@ security: - https://cognitiveservices.azure.com/.default components: schemas: - AzureChatCompletionResponseMessage: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - description: |- - The extended response model component for chat completion response messages on the Azure OpenAI service. - This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other - information related to retrieval-augmented generation performed. AzureChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. context: allOf: - $ref: '#/components/schemas/AzureChatMessageContext' description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' description: |- The extended response model for a streaming chat response message on the Azure OpenAI service. This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other @@ -472,43 +490,6 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. - AzureCompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - - completion_tokens_details - - prompt_tokens_details - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - reasoning_tokens: - type: integer - format: int32 - required: - - reasoning_tokens - prompt_tokens_details: - type: object - properties: - cached_tokens: - type: integer - format: int32 - required: - - cached_tokens AzureContentFilterBlocklistResult: type: object required: @@ -1041,7 +1022,6 @@ components: - created - model - object - - usage properties: id: type: string @@ -1124,7 +1104,7 @@ components: - chat.completion description: The object type, which is always `chat.completion`. usage: - $ref: '#/components/schemas/AzureCompletionUsage' + $ref: '#/components/schemas/OpenAI.CompletionUsage' prompt_filter_results: type: array items: @@ -2169,43 +2149,6 @@ components: type: boolean description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - audio: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' - description: Response audio associated with the streaming chat delta payload. - content: - type: string - nullable: true - description: The contents of the chunk message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. OpenAI.ChatCompletionTokenLogprob: type: object required: @@ -2349,6 +2292,65 @@ components: description: 'The type of response format being defined: `text`' allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + accepted_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that appeared in the completion. + audio_tokens: + type: integer + format: int32 + description: Audio input tokens generated by the model. + reasoning_tokens: + type: integer + format: int32 + description: Tokens generated by the model for reasoning. + rejected_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that did not appear in the completion. However, like + reasoning tokens, these tokens are still counted in the total + completion tokens for purposes of billing, output, and context window + limits. + description: Breakdown of tokens used in a completion. + prompt_tokens_details: + type: object + properties: + audio_tokens: + type: integer + format: int32 + description: Audio input tokens present in the prompt. + cached_tokens: + type: integer + format: int32 + description: Cached tokens present in the prompt. + description: Breakdown of tokens used in the prompt. + description: Usage statistics for the completion request. OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml index df7fef15d..adddb07ca 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml @@ -100,28 +100,46 @@ security: - https://cognitiveservices.azure.com/.default components: schemas: - AzureChatCompletionResponseMessage: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - description: |- - The extended response model component for chat completion response messages on the Azure OpenAI service. - This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other - information related to retrieval-augmented generation performed. AzureChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. context: allOf: - $ref: '#/components/schemas/AzureChatMessageContext' description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' description: |- The extended response model for a streaming chat response message on the Azure OpenAI service. This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other @@ -472,43 +490,6 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. - AzureCompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - - completion_tokens_details - - prompt_tokens_details - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - reasoning_tokens: - type: integer - format: int32 - required: - - reasoning_tokens - prompt_tokens_details: - type: object - properties: - cached_tokens: - type: integer - format: int32 - required: - - cached_tokens AzureContentFilterBlocklistResult: type: object required: @@ -1041,7 +1022,6 @@ components: - created - model - object - - usage properties: id: type: string @@ -1124,7 +1104,7 @@ components: - chat.completion description: The object type, which is always `chat.completion`. usage: - $ref: '#/components/schemas/AzureCompletionUsage' + $ref: '#/components/schemas/OpenAI.CompletionUsage' prompt_filter_results: type: array items: @@ -2169,43 +2149,6 @@ components: type: boolean description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - audio: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' - description: Response audio associated with the streaming chat delta payload. - content: - type: string - nullable: true - description: The contents of the chunk message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. OpenAI.ChatCompletionTokenLogprob: type: object required: @@ -2349,6 +2292,65 @@ components: description: 'The type of response format being defined: `text`' allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + accepted_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that appeared in the completion. + audio_tokens: + type: integer + format: int32 + description: Audio input tokens generated by the model. + reasoning_tokens: + type: integer + format: int32 + description: Tokens generated by the model for reasoning. + rejected_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that did not appear in the completion. However, like + reasoning tokens, these tokens are still counted in the total + completion tokens for purposes of billing, output, and context window + limits. + description: Breakdown of tokens used in a completion. + prompt_tokens_details: + type: object + properties: + audio_tokens: + type: integer + format: int32 + description: Audio input tokens present in the prompt. + cached_tokens: + type: integer + format: int32 + description: Cached tokens present in the prompt. + description: Breakdown of tokens used in the prompt. + description: Usage statistics for the completion request. OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml index af55f023b..ccbb1c975 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml @@ -100,28 +100,46 @@ security: - https://cognitiveservices.azure.com/.default components: schemas: - AzureChatCompletionResponseMessage: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - description: |- - The extended response model component for chat completion response messages on the Azure OpenAI service. - This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other - information related to retrieval-augmented generation performed. AzureChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. context: allOf: - $ref: '#/components/schemas/AzureChatMessageContext' description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' description: |- The extended response model for a streaming chat response message on the Azure OpenAI service. This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other @@ -472,43 +490,6 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. - AzureCompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - - completion_tokens_details - - prompt_tokens_details - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - reasoning_tokens: - type: integer - format: int32 - required: - - reasoning_tokens - prompt_tokens_details: - type: object - properties: - cached_tokens: - type: integer - format: int32 - required: - - cached_tokens AzureContentFilterBlocklistResult: type: object required: @@ -1074,7 +1055,6 @@ components: - created - model - object - - usage properties: id: type: string @@ -1157,7 +1137,7 @@ components: - chat.completion description: The object type, which is always `chat.completion`. usage: - $ref: '#/components/schemas/AzureCompletionUsage' + $ref: '#/components/schemas/OpenAI.CompletionUsage' prompt_filter_results: type: array items: @@ -2246,43 +2226,6 @@ components: type: boolean description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - audio: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' - description: Response audio associated with the streaming chat delta payload. - content: - type: string - nullable: true - description: The contents of the chunk message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. OpenAI.ChatCompletionTokenLogprob: type: object required: @@ -2426,6 +2369,65 @@ components: description: 'The type of response format being defined: `text`' allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + accepted_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that appeared in the completion. + audio_tokens: + type: integer + format: int32 + description: Audio input tokens generated by the model. + reasoning_tokens: + type: integer + format: int32 + description: Tokens generated by the model for reasoning. + rejected_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that did not appear in the completion. However, like + reasoning tokens, these tokens are still counted in the total + completion tokens for purposes of billing, output, and context window + limits. + description: Breakdown of tokens used in a completion. + prompt_tokens_details: + type: object + properties: + audio_tokens: + type: integer + format: int32 + description: Audio input tokens present in the prompt. + cached_tokens: + type: integer + format: int32 + description: Cached tokens present in the prompt. + description: Breakdown of tokens used in the prompt. + description: Usage statistics for the completion request. OpenAI.CreateImageRequest: type: object required: diff --git a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml index e3024692a..1df9d1f44 100644 --- a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml @@ -100,28 +100,46 @@ security: - https://cognitiveservices.azure.com/.default components: schemas: - AzureChatCompletionResponseMessage: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - description: |- - The extended response model component for chat completion response messages on the Azure OpenAI service. - This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other - information related to retrieval-augmented generation performed. AzureChatCompletionStreamResponseDelta: type: object properties: + audio: + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' + description: Response audio associated with the streaming chat delta payload. + content: + type: string + nullable: true + description: The contents of the chunk message. + function_call: + type: object + properties: + name: + type: string + arguments: + type: string + description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + deprecated: true + tool_calls: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' + role: + type: string + enum: + - system + - user + - assistant + - tool + description: The role of the author of this message. + refusal: + type: string + nullable: true + description: The refusal message generated by the model. context: allOf: - $ref: '#/components/schemas/AzureChatMessageContext' description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' description: |- The extended response model for a streaming chat response message on the Azure OpenAI service. This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other @@ -472,43 +490,6 @@ components: description: |- An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using extension behavior. This includes intent and citation information from the On Your Data feature. - AzureCompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - - completion_tokens_details - - prompt_tokens_details - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - reasoning_tokens: - type: integer - format: int32 - required: - - reasoning_tokens - prompt_tokens_details: - type: object - properties: - cached_tokens: - type: integer - format: int32 - required: - - cached_tokens AzureContentFilterBlocklistResult: type: object required: @@ -1124,7 +1105,6 @@ components: - created - model - object - - usage properties: id: type: string @@ -1207,7 +1187,7 @@ components: - chat.completion description: The object type, which is always `chat.completion`. usage: - $ref: '#/components/schemas/AzureCompletionUsage' + $ref: '#/components/schemas/OpenAI.CompletionUsage' prompt_filter_results: type: array items: @@ -2314,43 +2294,6 @@ components: type: boolean description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - audio: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageAudioChunk' - description: Response audio associated with the streaming chat delta payload. - content: - type: string - nullable: true - description: The contents of the chunk message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. OpenAI.ChatCompletionTokenLogprob: type: object required: @@ -2494,6 +2437,65 @@ components: description: 'The type of response format being defined: `text`' allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' + OpenAI.CompletionUsage: + type: object + required: + - completion_tokens + - prompt_tokens + - total_tokens + properties: + completion_tokens: + type: integer + format: int32 + description: Number of tokens in the generated completion. + prompt_tokens: + type: integer + format: int32 + description: Number of tokens in the prompt. + total_tokens: + type: integer + format: int32 + description: Total number of tokens used in the request (prompt + completion). + completion_tokens_details: + type: object + properties: + accepted_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that appeared in the completion. + audio_tokens: + type: integer + format: int32 + description: Audio input tokens generated by the model. + reasoning_tokens: + type: integer + format: int32 + description: Tokens generated by the model for reasoning. + rejected_prediction_tokens: + type: integer + format: int32 + description: |- + When using Predicted Outputs, the number of tokens in the + prediction that did not appear in the completion. However, like + reasoning tokens, these tokens are still counted in the total + completion tokens for purposes of billing, output, and context window + limits. + description: Breakdown of tokens used in a completion. + prompt_tokens_details: + type: object + properties: + audio_tokens: + type: integer + format: int32 + description: Audio input tokens present in the prompt. + cached_tokens: + type: integer + format: int32 + description: Cached tokens present in the prompt. + description: Breakdown of tokens used in the prompt. + description: Usage statistics for the completion request. OpenAI.CreateImageRequest: type: object required: diff --git a/.typespec.azure/chat/models.response.tsp b/.typespec.azure/chat/models.response.tsp index 58b348584..5d0e203ce 100644 --- a/.typespec.azure/chat/models.response.tsp +++ b/.typespec.azure/chat/models.response.tsp @@ -3,31 +3,12 @@ import "../common"; namespace AzureOpenAI; -@withoutOmittedProperties("completion_tokens_details") -@withoutOmittedProperties("prompt_tokens_details") -model CompletionUsageCommonBase is OpenAI.CompletionUsage; - -model AzureCompletionUsage { - ...CompletionUsageCommonBase; - completion_tokens_details: { - reasoning_tokens: int32; - }; - prompt_tokens_details: { - cached_tokens: int32; - }; -} - -@withoutOmittedProperties("usage") -model CreateChatCompletionResponseCommonBase - is OpenAI.CreateChatCompletionResponse; - /** * The extended top-level chat completion response model for the Azure OpenAI service. * This model adds Responsible AI content filter annotations for prompt input. */ model AzureCreateChatCompletionResponse { - ...CreateChatCompletionResponseCommonBase; - usage: AzureCompletionUsage; + ...OpenAI.CreateChatCompletionResponse; /** * The Responsible AI content filter annotations associated with prompt inputs into chat completions. @@ -79,8 +60,9 @@ model AzureChatMessageContext { * This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other * information related to retrieval-augmented generation performed. */ -model AzureChatCompletionResponseMessage - extends OpenAI.ChatCompletionResponseMessage { +model AzureChatCompletionResponseMessage { + ...OpenAI.ChatCompletionResponseMessage; + /** * The Azure-specific context information associated with the chat completion response message. */ @@ -92,8 +74,9 @@ model AzureChatCompletionResponseMessage * This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other * information related to retrieval-augmented generation performed. */ -model AzureChatCompletionStreamResponseDelta - extends OpenAI.ChatCompletionStreamResponseDelta { +model AzureChatCompletionStreamResponseDelta { + ...OpenAI.ChatCompletionStreamResponseDelta; + /** * The Azure-specific context information associated with the chat completion response message. */ From 5e4302357b910b7616b79878277f20557824142a Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 22 Jan 2025 18:09:04 -0800 Subject: [PATCH 24/44] several more versioning accuracy adjustments for the Azure spec --- ...hatDataSourceModelIdVectorizationSource.cs | 2 +- ...pi3-azure-openai-2024-06-01-generated.yaml | 442 +-- ...e-openai-2024-08-01-preview-generated.yaml | 17 +- ...e-openai-2024-09-01-preview-generated.yaml | 17 +- ...e-openai-2024-10-01-preview-generated.yaml | 17 +- ...pi3-azure-openai-2024-10-21-generated.yaml | 436 +-- ...e-openai-2024-11-01-preview-generated.yaml | 3197 ----------------- ...e-openai-2024-12-01-preview-generated.yaml | 13 +- ...e-openai-2025-01-01-preview-generated.yaml | 13 +- .typespec.azure/chat/models.oyd.auth.tsp | 43 +- .../chat/models.oyd.vectorization.tsp | 9 + .typespec.azure/chat/models.request.tsp | 68 +- .typespec.azure/chat/models.response.tsp | 16 + 13 files changed, 128 insertions(+), 4162 deletions(-) delete mode 100644 .openapi3.azure/openapi3-azure-openai-2024-11-01-preview-generated.yaml diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.cs index 5db5e3c5e..cfc74a0b9 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.cs @@ -16,7 +16,7 @@ internal partial class InternalAzureChatDataSourceModelIdVectorizationSource : D /// Initializes a new instance of . /// The embedding model build ID to use for vectorization. /// is null. - internal InternalAzureChatDataSourceModelIdVectorizationSource(string modelId) + public InternalAzureChatDataSourceModelIdVectorizationSource(string modelId) { Argument.AssertNotNull(modelId, nameof(modelId)); diff --git a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml index df85f1fe0..5ccf8fe35 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml @@ -156,29 +156,12 @@ components: propertyName: type mapping: azure_search: '#/components/schemas/AzureSearchChatDataSource' - azure_ml_index: '#/components/schemas/AzureMachineLearningIndexChatDataSource' azure_cosmos_db: '#/components/schemas/AzureCosmosDBChatDataSource' - elasticsearch: '#/components/schemas/ElasticsearchChatDataSource' - pinecone: '#/components/schemas/PineconeChatDataSource' description: |- A representation of configuration data for a single Azure OpenAI chat data source. This will be used by a chat completions request that should use Azure OpenAI chat extensions to augment the response behavior. The use of this configuration is compatible only with Azure OpenAI. - AzureChatDataSourceAccessTokenAuthenticationOptions: - type: object - required: - - type - - access_token - properties: - type: - type: string - enum: - - access_token - access_token: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' AzureChatDataSourceApiKeyAuthenticationOptions: type: object required: @@ -204,9 +187,6 @@ components: propertyName: type mapping: connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' - key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' - encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' - access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' AzureChatDataSourceConnectionStringAuthenticationOptions: @@ -251,20 +231,6 @@ components: Represents a vectorization source that makes internal service calls against an Azure OpenAI embedding model deployment. In contrast with the endpoint-based vectorization source, a deployment-name-based vectorization source must be part of the same Azure OpenAI resource but can be used even in private networks. - AzureChatDataSourceEncodedApiKeyAuthenticationOptions: - type: object - required: - - type - - encoded_api_key - properties: - type: - type: string - enum: - - encoded_api_key - encoded_api_key: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' AzureChatDataSourceEndpointVectorizationSource: type: object required: @@ -286,9 +252,8 @@ components: https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. The api-version query parameter is not allowed. authentication: - anyOf: + allOf: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: |- The authentication mechanism to use with the endpoint-based vectorization source. Endpoint authentication supports API key and access token mechanisms. @@ -301,42 +266,6 @@ components: allOf: - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' description: Represents a vectorization source that makes public service calls against an Azure OpenAI embedding model deployment. - AzureChatDataSourceKeyAndKeyIdAuthenticationOptions: - type: object - required: - - type - - key - - key_id - properties: - type: - type: string - enum: - - key_and_key_id - key: - type: string - key_id: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceModelIdVectorizationSource: - type: object - required: - - type - - model_id - properties: - type: - type: string - enum: - - model_id - description: The type identifier, always 'model_id' for this vectorization source type. - model_id: - type: string - description: The embedding model build ID to use for vectorization. - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: |- - Represents a vectorization source that makes service calls based on a search service model ID. - This source type is currently only supported by Elasticsearch. AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions: type: object required: @@ -373,8 +302,8 @@ components: discriminator: propertyName: type mapping: + endpoint: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' description: A representation of a data vectorization source usable as an embedding resource with a data source. AzureChatMessageContext: type: object @@ -926,7 +855,12 @@ components: $ref: '#/components/schemas/OpenAI.ChatCompletionTool' description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' + anyOf: + - type: string + enum: + - none + - auto + - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' user: type: string description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). @@ -1097,94 +1031,6 @@ components: $ref: '#/components/schemas/AzureContentFilterImageResponseResults' allOf: - $ref: '#/components/schemas/OpenAI.Image' - AzureMachineLearningIndexChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - azure_ml_index - description: The discriminated type identifier, which is always 'azure_ml_index'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - role_information: - type: string - description: |- - Additional instructions for the model to inform how it should behave and any context it should reference when - generating a response. You can describe the assistant's personality and tell it how to format responses. - This is limited to 100 tokens and counts against the overall token limit. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - project_resource_id: - type: string - description: The ID of the Azure Machine Learning index project to use. - name: - type: string - description: The name of the Azure Machine Learning index to use. - version: - type: string - description: The version of the vector index to use. - filter: - type: string - description: A search filter, which is only applicable if the vector index is of the 'AzureSearch' type. - required: - - authentication - - project_resource_id - - name - - version - description: The parameter information to control the use of the Azure Machine Learning Index data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Machine Learning vector index. AzureOpenAIChatError: type: object properties: @@ -1335,7 +1181,6 @@ components: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: The authentication mechanism to use with Azure Search. fields_mapping: type: object @@ -1384,9 +1229,8 @@ components: type: string description: A filter to apply to the search. embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' description: |- The vectorization source to use with Azure Search. Supported sources for Azure Search include endpoint, deployment name, and integrated. @@ -1427,110 +1271,6 @@ components: required: - file_id - tools - ElasticsearchChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - elasticsearch - description: The discriminated type identifier, which is always 'elasticsearch'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - role_information: - type: string - description: |- - Additional instructions for the model to inform how it should behave and any context it should reference when - generating a response. You can describe the assistant's personality and tell it how to format responses. - This is limited to 100 tokens and counts against the overall token limit. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - format: uri - index_name: - type: string - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' - fields_mapping: - type: object - properties: - title_field: - type: string - url_field: - type: string - filepath_field: - type: string - content_fields: - type: array - items: - type: string - content_fields_separator: - type: string - vector_fields: - type: array - items: - type: string - query_type: - type: string - enum: - - simple - - vector - embedding_dependency: - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Elasticsearch data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' MessageObjectAttachments: type: array items: @@ -2105,23 +1845,6 @@ components: description: The type of the tool. Currently, only `function` is supported. function: $ref: '#/components/schemas/OpenAI.FunctionObject' - OpenAI.ChatCompletionToolChoiceOption: - anyOf: - - type: string - enum: - - none - - auto - - required - - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' - description: |- - Controls which (if any) tool is called by the model. - `none` means the model will not call any tool and instead generates a message. - `auto` means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools. - Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - `none` is the default when no tools are present. `auto` is the default if tools are present. - x-oaiExpandable: true OpenAI.ChatResponseFormat: type: object required: @@ -2134,7 +1857,6 @@ components: mapping: text: '#/components/schemas/OpenAI.ChatResponseFormatText' json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' - json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' OpenAI.ChatResponseFormatJsonObject: type: object required: @@ -2147,37 +1869,6 @@ components: description: 'The type of response format being defined: `json_object`' allOf: - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatJsonSchema: - type: object - required: - - type - - json_schema - properties: - type: - type: string - enum: - - json_schema - description: 'The type of response format being defined: `json_schema`' - json_schema: - type: object - properties: - description: - type: string - description: A description of what the response format is for, used by the model to determine how to respond in the format. - name: - type: string - description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - schema: - $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). - default: false - required: - - name - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' OpenAI.ChatResponseFormatText: type: object required: @@ -2718,119 +2409,6 @@ components: allOf: - $ref: '#/components/schemas/OpenAI.MessageContent' description: The text content that is part of a message. - OpenAI.ResponseFormatJsonSchemaSchema: - type: object - additionalProperties: {} - description: The schema for the response format, described as a JSON Schema object. - PineconeChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - pinecone - description: The discriminated type identifier, which is always 'pinecone'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - role_information: - type: string - description: |- - Additional instructions for the model to inform how it should behave and any context it should reference when - generating a response. You can describe the assistant's personality and tell it how to format responses. - This is limited to 100 tokens and counts against the overall token limit. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - environment: - type: string - description: The environment name to use with Pinecone. - index_name: - type: string - description: The name of the Pinecone database index to use. - authentication: - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - description: |- - The authentication mechanism to use with Pinecone. - Supported authentication mechanisms for Pinecone include: API key. - embedding_dependency: - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: |- - The vectorization source to use as an embedding dependency for the Pinecone data source. - Supported vectorization sources for Pinecone include: deployment name. - fields_mapping: - type: object - properties: - content_fields: - type: array - items: - type: string - title_field: - type: string - url_field: - type: string - filepath_field: - type: string - content_fields_separator: - type: string - required: - - content_fields - description: |- - Field mappings to apply to data used by the Pinecone data source. - Note that content field mappings are required for Pinecone. - required: - - environment - - index_name - - authentication - - embedding_dependency - - fields_mapping - description: The parameter information to control the use of the Pinecone data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' securitySchemes: ApiKeyAuth: type: apiKey diff --git a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml index c08ffa725..30aaca70a 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml @@ -203,13 +203,13 @@ components: discriminator: propertyName: type mapping: - username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' AzureChatDataSourceConnectionStringAuthenticationOptions: type: object required: @@ -287,9 +287,8 @@ components: https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. The api-version query parameter is not allowed. authentication: - anyOf: + allOf: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: |- The authentication mechanism to use with the endpoint-based vectorization source. Endpoint authentication supports API key and access token mechanisms. @@ -404,6 +403,7 @@ components: discriminator: propertyName: type mapping: + endpoint: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' @@ -1267,7 +1267,6 @@ components: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: The authentication mechanism to use with Azure Search. fields_mapping: type: object @@ -1316,10 +1315,8 @@ components: type: string description: A filter to apply to the search. embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' description: |- The vectorization source to use with Azure Search. Supported sources for Azure Search include endpoint, deployment name, and integrated. diff --git a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml index e03b8b347..09e834bfb 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml @@ -203,13 +203,13 @@ components: discriminator: propertyName: type mapping: - username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' AzureChatDataSourceConnectionStringAuthenticationOptions: type: object required: @@ -287,9 +287,8 @@ components: https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. The api-version query parameter is not allowed. authentication: - anyOf: + allOf: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: |- The authentication mechanism to use with the endpoint-based vectorization source. Endpoint authentication supports API key and access token mechanisms. @@ -404,6 +403,7 @@ components: discriminator: propertyName: type mapping: + endpoint: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' @@ -1281,7 +1281,6 @@ components: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: The authentication mechanism to use with Azure Search. fields_mapping: type: object @@ -1330,10 +1329,8 @@ components: type: string description: A filter to apply to the search. embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' description: |- The vectorization source to use with Azure Search. Supported sources for Azure Search include endpoint, deployment name, and integrated. diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml index 5a91a3487..4642a176b 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml @@ -203,13 +203,13 @@ components: discriminator: propertyName: type mapping: - username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' AzureChatDataSourceConnectionStringAuthenticationOptions: type: object required: @@ -287,9 +287,8 @@ components: https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. The api-version query parameter is not allowed. authentication: - anyOf: + allOf: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: |- The authentication mechanism to use with the endpoint-based vectorization source. Endpoint authentication supports API key and access token mechanisms. @@ -404,6 +403,7 @@ components: discriminator: propertyName: type mapping: + endpoint: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' @@ -1281,7 +1281,6 @@ components: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: The authentication mechanism to use with Azure Search. fields_mapping: type: object @@ -1330,10 +1329,8 @@ components: type: string description: A filter to apply to the search. embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' description: |- The vectorization source to use with Azure Search. Supported sources for Azure Search include endpoint, deployment name, and integrated. diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml index adddb07ca..6887a8d56 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml @@ -157,28 +157,11 @@ components: mapping: azure_search: '#/components/schemas/AzureSearchChatDataSource' azure_cosmos_db: '#/components/schemas/AzureCosmosDBChatDataSource' - elasticsearch: '#/components/schemas/ElasticsearchChatDataSource' - pinecone: '#/components/schemas/PineconeChatDataSource' - mongo_db: '#/components/schemas/MongoDBChatDataSource' description: |- A representation of configuration data for a single Azure OpenAI chat data source. This will be used by a chat completions request that should use Azure OpenAI chat extensions to augment the response behavior. The use of this configuration is compatible only with Azure OpenAI. - AzureChatDataSourceAccessTokenAuthenticationOptions: - type: object - required: - - type - - access_token - properties: - type: - type: string - enum: - - access_token - access_token: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' AzureChatDataSourceApiKeyAuthenticationOptions: type: object required: @@ -203,11 +186,7 @@ components: discriminator: propertyName: type mapping: - username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' - key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' - encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' - access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' AzureChatDataSourceConnectionStringAuthenticationOptions: @@ -252,20 +231,6 @@ components: Represents a vectorization source that makes internal service calls against an Azure OpenAI embedding model deployment. In contrast with the endpoint-based vectorization source, a deployment-name-based vectorization source must be part of the same Azure OpenAI resource but can be used even in private networks. - AzureChatDataSourceEncodedApiKeyAuthenticationOptions: - type: object - required: - - type - - encoded_api_key - properties: - type: - type: string - enum: - - encoded_api_key - encoded_api_key: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' AzureChatDataSourceEndpointVectorizationSource: type: object required: @@ -287,9 +252,8 @@ components: https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. The api-version query parameter is not allowed. authentication: - anyOf: + allOf: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: |- The authentication mechanism to use with the endpoint-based vectorization source. Endpoint authentication supports API key and access token mechanisms. @@ -302,55 +266,6 @@ components: allOf: - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' description: Represents a vectorization source that makes public service calls against an Azure OpenAI embedding model deployment. - AzureChatDataSourceIntegratedVectorizationSource: - type: object - required: - - type - properties: - type: - type: string - enum: - - integrated - description: The type identifier, always 'integrated' for this vectorization source type. - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: Represents an integrated vectorization source as defined within the supporting search resource. - AzureChatDataSourceKeyAndKeyIdAuthenticationOptions: - type: object - required: - - type - - key - - key_id - properties: - type: - type: string - enum: - - key_and_key_id - key: - type: string - key_id: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceModelIdVectorizationSource: - type: object - required: - - type - - model_id - properties: - type: - type: string - enum: - - model_id - description: The type identifier, always 'model_id' for this vectorization source type. - model_id: - type: string - description: The embedding model build ID to use for vectorization. - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: |- - Represents a vectorization source that makes service calls based on a search service model ID. - This source type is currently only supported by Elasticsearch. AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions: type: object required: @@ -376,23 +291,6 @@ components: type: string allOf: - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceUsernameAndPasswordAuthenticationOptions: - type: object - required: - - type - - username - - password - properties: - type: - type: string - enum: - - username_and_password - username: - type: string - password: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' AzureChatDataSourceVectorizationSource: type: object required: @@ -404,9 +302,8 @@ components: discriminator: propertyName: type mapping: + endpoint: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' - integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' description: A representation of a data vectorization source usable as an embedding resource with a data source. AzureChatMessageContext: type: object @@ -1281,7 +1178,6 @@ components: - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' description: The authentication mechanism to use with Azure Search. fields_mapping: type: object @@ -1330,10 +1226,8 @@ components: type: string description: A filter to apply to the search. embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' description: |- The vectorization source to use with Azure Search. Supported sources for Azure Search include endpoint, deployment name, and integrated. @@ -1374,104 +1268,6 @@ components: required: - file_id - tools - ElasticsearchChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - elasticsearch - description: The discriminated type identifier, which is always 'elasticsearch'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - format: uri - index_name: - type: string - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' - fields_mapping: - type: object - properties: - title_field: - type: string - url_field: - type: string - filepath_field: - type: string - content_fields: - type: array - items: - type: string - content_fields_separator: - type: string - vector_fields: - type: array - items: - type: string - query_type: - type: string - enum: - - simple - - vector - embedding_dependency: - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Elasticsearch data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' MessageObjectAttachments: type: array items: @@ -1488,127 +1284,6 @@ components: - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' description: The tools to add this file to. x-oaiExpandable: true - MongoDBChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - mongo_db - description: The discriminated type identifier, which is always 'mongo_db'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - description: The name of the MongoDB cluster endpoint. - database_name: - type: string - description: The name of the MongoDB database. - collection_name: - type: string - description: The name of the MongoDB collection. - app_name: - type: string - description: The name of the MongoDB application. - index_name: - type: string - description: The name of the MongoDB index. - authentication: - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' - description: |- - The authentication mechanism to use with Pinecone. - Supported authentication mechanisms for Pinecone include: username and password. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - description: |- - The vectorization source to use as an embedding dependency for the MongoDB data source. - Supported vectorization sources for MongoDB include: endpoint, deployment name. - fields_mapping: - type: object - properties: - content_fields: - type: array - items: - type: string - vector_fields: - type: array - items: - type: string - title_field: - type: string - url_field: - type: string - filepath_field: - type: string - content_fields_separator: - type: string - required: - - content_fields - - vector_fields - description: |- - Field mappings to apply to data used by the MongoDB data source. - Note that content and vector field mappings are required for MongoDB. - required: - - endpoint - - database_name - - collection_name - - app_name - - index_name - - authentication - - embedding_dependency - - fields_mapping - description: The parameter information to control the use of the MongoDB data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' OpenAI.AssistantToolDefinition: type: object required: @@ -2863,109 +2538,6 @@ components: type: object additionalProperties: {} description: The schema for the response format, described as a JSON Schema object. - PineconeChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - pinecone - description: The discriminated type identifier, which is always 'pinecone'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - environment: - type: string - description: The environment name to use with Pinecone. - index_name: - type: string - description: The name of the Pinecone database index to use. - authentication: - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - description: |- - The authentication mechanism to use with Pinecone. - Supported authentication mechanisms for Pinecone include: API key. - embedding_dependency: - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: |- - The vectorization source to use as an embedding dependency for the Pinecone data source. - Supported vectorization sources for Pinecone include: deployment name. - fields_mapping: - type: object - properties: - content_fields: - type: array - items: - type: string - title_field: - type: string - url_field: - type: string - filepath_field: - type: string - content_fields_separator: - type: string - required: - - content_fields - description: |- - Field mappings to apply to data used by the Pinecone data source. - Note that content field mappings are required for Pinecone. - required: - - environment - - index_name - - authentication - - embedding_dependency - - fields_mapping - description: The parameter information to control the use of the Pinecone data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' securitySchemes: ApiKeyAuth: type: apiKey diff --git a/.openapi3.azure/openapi3-azure-openai-2024-11-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-11-01-preview-generated.yaml deleted file mode 100644 index 325032619..000000000 --- a/.openapi3.azure/openapi3-azure-openai-2024-11-01-preview-generated.yaml +++ /dev/null @@ -1,3197 +0,0 @@ -openapi: 3.0.0 -info: - title: Azure OpenAI Service - version: 2024-12-01-preview -tags: - - name: Chat - - name: Images - - name: Assistants -paths: - /chat/completions: - post: - operationId: createChatCompletion - parameters: [] - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/AzureCreateChatCompletionResponse' - - $ref: '#/components/schemas/AzureOpenAIChatErrorResponse' - tags: - - Chat - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/AzureCreateChatCompletionRequest' - /deployments/{deploymentId}/images/generations: - post: - operationId: ImageGenerations_Create - parameters: - - name: deploymentId - in: path - required: true - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.ImagesResponse' - - $ref: '#/components/schemas/AzureOpenAIDalleErrorResponse' - tags: - - Images - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAI.CreateImageRequest' - /threads/{thread_id}/messages: - post: - operationId: createMessage - summary: Create a message. - parameters: - - name: thread_id - in: path - required: true - description: The ID of the [thread](/docs/api-reference/threads) to create a message for. - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAI.MessageObject' - default: - description: An unexpected error response. - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAI.ErrorResponse' - tags: - - Assistants - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAI.CreateMessageRequest' -security: - - ApiKeyAuth: [] - - OAuth2Auth: - - https://cognitiveservices.azure.com/.default -components: - schemas: - AzureChatCompletionResponseMessage: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - description: |- - The extended response model component for chat completion response messages on the Azure OpenAI service. - This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other - information related to retrieval-augmented generation performed. - AzureChatCompletionStreamResponseDelta: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamResponseDelta' - description: |- - The extended response model for a streaming chat response message on the Azure OpenAI service. - This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other - information related to retrieval-augmented generation performed. - AzureChatDataSource: - type: object - required: - - type - properties: - type: - type: string - description: The differentiating type identifier for the data source. - discriminator: - propertyName: type - mapping: - azure_search: '#/components/schemas/AzureSearchChatDataSource' - azure_cosmos_db: '#/components/schemas/AzureCosmosDBChatDataSource' - elasticsearch: '#/components/schemas/ElasticsearchChatDataSource' - pinecone: '#/components/schemas/PineconeChatDataSource' - mongo_db: '#/components/schemas/MongoDBChatDataSource' - description: |- - A representation of configuration data for a single Azure OpenAI chat data source. - This will be used by a chat completions request that should use Azure OpenAI chat extensions to augment the - response behavior. - The use of this configuration is compatible only with Azure OpenAI. - AzureChatDataSourceAccessTokenAuthenticationOptions: - type: object - required: - - type - - access_token - properties: - type: - type: string - enum: - - access_token - access_token: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceApiKeyAuthenticationOptions: - type: object - required: - - type - - key - properties: - type: - type: string - enum: - - api_key - key: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceAuthenticationOptions: - type: object - required: - - type - properties: - type: - type: string - discriminator: - propertyName: type - mapping: - username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' - connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' - key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' - encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' - access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - AzureChatDataSourceConnectionStringAuthenticationOptions: - type: object - required: - - type - - connection_string - properties: - type: - type: string - enum: - - connection_string - connection_string: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceDeploymentNameVectorizationSource: - type: object - required: - - type - - deployment_name - properties: - type: - type: string - enum: - - deployment_name - description: The type identifier, always 'deployment_name' for this vectorization source type. - deployment_name: - type: string - description: |- - The embedding model deployment to use for vectorization. This deployment must exist within the same Azure OpenAI - resource as the model deployment being used for chat completions. - dimensions: - type: integer - format: int32 - description: |- - The number of dimensions to request on embeddings. - Only supported in 'text-embedding-3' and later models. - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: |- - Represents a vectorization source that makes internal service calls against an Azure OpenAI embedding model - deployment. In contrast with the endpoint-based vectorization source, a deployment-name-based vectorization source - must be part of the same Azure OpenAI resource but can be used even in private networks. - AzureChatDataSourceEncodedApiKeyAuthenticationOptions: - type: object - required: - - type - - encoded_api_key - properties: - type: - type: string - enum: - - encoded_api_key - encoded_api_key: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceEndpointVectorizationSource: - type: object - required: - - type - - endpoint - - authentication - properties: - type: - type: string - enum: - - endpoint - description: The type identifier, always 'endpoint' for this vectorization source type. - endpoint: - type: string - format: uri - description: |- - Specifies the resource endpoint URL from which embeddings should be retrieved. - It should be in the format of: - https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. - The api-version query parameter is not allowed. - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - description: |- - The authentication mechanism to use with the endpoint-based vectorization source. - Endpoint authentication supports API key and access token mechanisms. - dimensions: - type: integer - format: int32 - description: |- - The number of dimensions to request on embeddings. - Only supported in 'text-embedding-3' and later models. - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: Represents a vectorization source that makes public service calls against an Azure OpenAI embedding model deployment. - AzureChatDataSourceIntegratedVectorizationSource: - type: object - required: - - type - properties: - type: - type: string - enum: - - integrated - description: The type identifier, always 'integrated' for this vectorization source type. - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: Represents an integrated vectorization source as defined within the supporting search resource. - AzureChatDataSourceKeyAndKeyIdAuthenticationOptions: - type: object - required: - - type - - key - - key_id - properties: - type: - type: string - enum: - - key_and_key_id - key: - type: string - key_id: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceModelIdVectorizationSource: - type: object - required: - - type - - model_id - properties: - type: - type: string - enum: - - model_id - description: The type identifier, always 'model_id' for this vectorization source type. - model_id: - type: string - description: The embedding model build ID to use for vectorization. - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: |- - Represents a vectorization source that makes service calls based on a search service model ID. - This source type is currently only supported by Elasticsearch. - AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions: - type: object - required: - - type - properties: - type: - type: string - enum: - - system_assigned_managed_identity - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions: - type: object - required: - - type - - managed_identity_resource_id - properties: - type: - type: string - enum: - - user_assigned_managed_identity - managed_identity_resource_id: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceUsernameAndPasswordAuthenticationOptions: - type: object - required: - - type - - username - - password - properties: - type: - type: string - enum: - - username_and_password - username: - type: string - password: - type: string - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceAuthenticationOptions' - AzureChatDataSourceVectorizationSource: - type: object - required: - - type - properties: - type: - type: string - description: The differentiating identifier for the concrete vectorization source. - discriminator: - propertyName: type - mapping: - deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' - integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' - description: A representation of a data vectorization source usable as an embedding resource with a data source. - AzureChatMessageContext: - type: object - properties: - intent: - type: string - description: The detected intent from the chat history, which is used to carry conversation context between interactions - citations: - type: array - items: - type: object - properties: - content: - type: string - description: The content of the citation. - title: - type: string - description: The title for the citation. - url: - type: string - description: The URL of the citation. - filepath: - type: string - description: The file path for the citation. - chunk_id: - type: string - description: The chunk ID for the citation. - rerank_score: - type: number - format: double - description: The rerank score for the retrieval. - required: - - content - description: The citations produced by the data retrieval. - all_retrieved_documents: - type: object - properties: - content: - type: string - description: The content of the citation. - title: - type: string - description: The title for the citation. - url: - type: string - description: The URL of the citation. - filepath: - type: string - description: The file path for the citation. - chunk_id: - type: string - description: The chunk ID for the citation. - rerank_score: - type: number - format: double - description: The rerank score for the retrieval. - search_queries: - type: array - items: - type: string - description: The search queries executed to retrieve documents. - data_source_index: - type: integer - format: int32 - description: The index of the data source used for retrieval. - original_search_score: - type: number - format: double - description: The original search score for the retrieval. - filter_reason: - type: string - enum: - - score - - rerank - description: If applicable, an indication of why the document was filtered. - required: - - content - - search_queries - - data_source_index - description: Summary information about documents retrieved by the data retrieval operation. - description: |- - An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using - extension behavior. This includes intent and citation information from the On Your Data feature. - AzureContentFilterBlocklistIdResult: - type: object - required: - - id - - filtered - properties: - id: - type: string - description: The ID of the custom blocklist associated with the filtered status. - filtered: - type: boolean - description: Whether the associated blocklist resulted in the content being filtered. - description: |- - A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not - the corresponding blocklist resulted in content being filtered. - AzureContentFilterBlocklistResult: - type: object - required: - - filtered - properties: - filtered: - type: boolean - description: A value indicating whether any of the detailed blocklists resulted in a filtering action. - details: - type: array - items: - type: object - properties: - filtered: - type: boolean - description: A value indicating whether the blocklist produced a filtering action. - id: - type: string - description: The ID of the custom blocklist evaluated. - required: - - filtered - - id - description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. - description: A collection of true/false filtering results for configured custom blocklists. - AzureContentFilterCompletionTextSpan: - type: object - required: - - completion_start_offset - - completion_end_offset - properties: - completion_start_offset: - type: integer - format: int32 - description: Offset of the UTF32 code point which begins the span. - completion_end_offset: - type: integer - format: int32 - description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. - description: A representation of a span of completion text as used by Azure OpenAI content filter results. - AzureContentFilterCompletionTextSpanDetectionResult: - type: object - required: - - filtered - - detected - - details - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - details: - type: array - items: - $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' - description: Detailed information about the detected completion text spans. - AzureContentFilterDetectionResult: - type: object - required: - - filtered - - detected - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - description: |- - A labeled content filter result item that indicates whether the content was detected and whether the content was - filtered. - AzureContentFilterImagePromptResults: - type: object - required: - - jailbreak - properties: - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - jailbreak: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that describes user prompt injection attacks, where malicious users deliberately exploit - system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content - generation or violations of system-imposed restrictions. - allOf: - - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' - description: A content filter result for an image generation operation's input request content. - AzureContentFilterImageResponseResults: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - description: A content filter result for an image generation operation's output response content. - AzureContentFilterResultForChoice: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - error: - type: object - properties: - code: - type: integer - format: int32 - description: A distinct, machine-readable code associated with the error. - message: - type: string - description: A human-readable message associated with the error. - required: - - code - - message - description: If present, details about an error that prevented content filtering from completing its evaluation. - protected_material_text: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: A detection result that describes a match against text protected under copyright or other status. - protected_material_code: - type: object - properties: - filtered: - type: boolean - description: Whether the content detection resulted in a content filtering action. - detected: - type: boolean - description: Whether the labeled content category was detected in the content. - citation: - type: object - properties: - license: - type: string - description: The name or identifier of the license associated with the detection. - URL: - type: string - format: uri - description: The URL associated with the license. - description: If available, the citation details describing the associated license and its location. - required: - - filtered - - detected - description: A detection result that describes a match against licensed code or other protected source material. - ungrounded_material: - $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' - description: A content filter result for a single response item produced by a generative AI system. - AzureContentFilterResultForPrompt: - type: object - properties: - prompt_index: - type: integer - format: int32 - description: The index of the input prompt associated with the accompanying content filter result categories. - content_filter_results: - type: object - properties: - sexual: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - hate: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - language with reference to a person or identity group based on certain differentiating attributes of these groups - including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - religion, immigration status, ability status, personal appearance, and body size. - violence: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - someone or something; describes weapons, guns and related entities, such as manufactures, associations, - legislation, and so on. - self_harm: - allOf: - - $ref: '#/components/schemas/AzureContentFilterSeverityResult' - description: |- - A content filter category that describes language related to physical actions intended to purposely hurt, injure, - damage one's body or kill oneself. - profanity: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - content. - custom_blocklists: - allOf: - - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' - description: A collection of binary filtering outcomes for configured custom blocklists. - error: - type: object - properties: - code: - type: integer - format: int32 - description: A distinct, machine-readable code associated with the error. - message: - type: string - description: A human-readable message associated with the error. - required: - - code - - message - description: If present, details about an error that prevented content filtering from completing its evaluation. - jailbreak: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that describes user prompt injection attacks, where malicious users deliberately exploit - system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content - generation or violations of system-imposed restrictions. - indirect_attack: - allOf: - - $ref: '#/components/schemas/AzureContentFilterDetectionResult' - description: |- - A detection result that describes attacks on systems powered by Generative AI models that can happen every time - an application processes information that wasn’t directly authored by either the developer of the application or - the user. - required: - - jailbreak - - indirect_attack - description: The content filter category details for the result. - description: A content filter result associated with a single input prompt item into a generative AI system. - AzureContentFilterSeverityResult: - type: object - required: - - filtered - - severity - properties: - filtered: - type: boolean - description: Whether the content severity resulted in a content filtering action. - severity: - type: string - enum: - - safe - - low - - medium - - high - description: The labeled severity of the content. - description: |- - A labeled content filter result item that indicates whether the content was filtered and what the qualitative - severity level of the content was, as evaluated against content filter configuration for the category. - AzureCosmosDBChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - azure_cosmos_db - description: The discriminated type identifier, which is always 'azure_cosmos_db'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - container_name: - type: string - database_name: - type: string - embedding_dependency: - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - index_name: - type: string - authentication: - $ref: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' - fields_mapping: - type: object - properties: - content_fields: - type: array - items: - type: string - vector_fields: - type: array - items: - type: string - title_field: - type: string - url_field: - type: string - filepath_field: - type: string - content_fields_separator: - type: string - required: - - content_fields - - vector_fields - required: - - container_name - - database_name - - embedding_dependency - - index_name - - authentication - - fields_mapping - description: The parameter information to control the use of the Azure CosmosDB data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure CosmosDB resource. - AzureCreateChatCompletionRequest: - type: object - properties: - data_sources: - type: array - items: - $ref: '#/components/schemas/AzureChatDataSource' - description: The data sources to use for the On Your Data feature, exclusive to Azure OpenAI. - user_security_context: - $ref: '#/components/schemas/AzureUserSecurityContext' - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionRequest' - description: |- - The extended request model for chat completions against the Azure OpenAI service. - This adds the ability to provide data sources for the On Your Data feature. - AzureCreateChatCompletionResponse: - type: object - properties: - prompt_filter_results: - type: array - items: - type: object - properties: - prompt_index: - type: integer - format: int32 - description: The index of the input prompt that this content filter result corresponds to. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter results associated with the indexed input prompt. - required: - - prompt_index - - content_filter_results - description: The Responsible AI content filter annotations associated with prompt inputs into chat completions. - allOf: - - $ref: '#/components/schemas/OpenAI.CreateChatCompletionResponse' - description: |- - The extended top-level chat completion response model for the Azure OpenAI service. - This model adds Responsible AI content filter annotations for prompt input. - AzureImage: - type: object - required: - - prompt_filter_results - - content_filter_results - properties: - prompt_filter_results: - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - content_filter_results: - $ref: '#/components/schemas/AzureContentFilterImageResponseResults' - allOf: - - $ref: '#/components/schemas/OpenAI.Image' - AzureOpenAIChatError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: - type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterResultForPrompt' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI chat completion request. - AzureOpenAIChatErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIChatError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIDalleError: - type: object - properties: - code: - type: string - description: The distinct, machine-generated identifier for the error. - message: - type: string - description: A human-readable message associated with the error. - param: - type: string - description: If applicable, the request input parameter associated with the error - type: - type: string - description: If applicable, the input line number associated with the error. - inner_error: - type: object - properties: - code: - type: string - enum: - - ResponsibleAIPolicyViolation - description: The code associated with the inner error. - revised_prompt: - type: string - description: If applicable, the modified prompt used for generation. - content_filter_results: - allOf: - - $ref: '#/components/schemas/AzureContentFilterImagePromptResults' - description: The content filter result details associated with the inner error. - description: If applicable, an upstream error that originated this error. - description: The structured representation of an error from an Azure OpenAI image generation request. - AzureOpenAIDalleErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/AzureOpenAIDalleError' - description: A structured representation of an error an Azure OpenAI request. - AzureOpenAIFile: - type: object - required: - - id - - bytes - - created_at - - filename - - object - - purpose - - status - properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 - nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - enum: - - file - description: The object type, which is always `file`. - purpose: - type: string - enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - status_details: - type: string - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. - deprecated: true - status: - type: string - enum: - - uploaded - - pending - - running - - processed - - error - - deleting - - deleted - AzureOpenAIServiceApiVersion: - type: string - enum: - - 2024-06-01 - - 2024-08-01-preview - - 2024-09-01-preview - - 2024-10-01-preview - - 2024-10-21 - - 2024-12-01-preview - description: Known service API versions for Azure OpenAI. - AzureSearchChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - azure_search - description: The discriminated type identifier, which is always 'azure_search'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - format: uri - description: The absolute endpoint path for the Azure Search resource to use. - index_name: - type: string - description: The name of the index to use, as specified in the Azure Search resource. - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - description: The authentication mechanism to use with Azure Search. - fields_mapping: - type: object - properties: - title_field: - type: string - description: The name of the index field to use as a title. - url_field: - type: string - description: The name of the index field to use as a URL. - filepath_field: - type: string - description: The name of the index field to use as a filepath. - content_fields: - type: array - items: - type: string - description: The names of index fields that should be treated as content. - content_fields_separator: - type: string - description: The separator pattern that content fields should use. - vector_fields: - type: array - items: - type: string - description: The names of fields that represent vector data. - image_vector_fields: - type: array - items: - type: string - description: The names of fields that represent image vector data. - description: The field mappings to use with the Azure Search resource. - query_type: - type: string - enum: - - simple - - semantic - - vector - - vector_simple_hybrid - - vector_semantic_hybrid - description: The query type for the Azure Search resource to use. - semantic_configuration: - type: string - description: Additional semantic configuration for the query. - filter: - type: string - description: A filter to apply to the search. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' - description: |- - The vectorization source to use with Azure Search. - Supported sources for Azure Search include endpoint, deployment name, and integrated. - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Azure Search data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - description: Represents a data source configuration that will use an Azure Search resource. - AzureUserSecurityContext: - type: object - properties: - application_name: - type: string - description: The name of the application. Sensitive personal information should not be included in this field. - end_user_id: - type: string - description: This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. - end_user_tenant_id: - type: string - description: The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. - source_ip: - type: string - description: Captures the original client's IP address. - description: User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. - ChatCompletionMessageToolCallsItem: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' - description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 - CreateMessageRequestAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools - ElasticsearchChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - elasticsearch - description: The discriminated type identifier, which is always 'elasticsearch'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - format: uri - index_name: - type: string - authentication: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' - - $ref: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' - fields_mapping: - type: object - properties: - title_field: - type: string - url_field: - type: string - filepath_field: - type: string - content_fields: - type: array - items: - type: string - content_fields_separator: - type: string - vector_fields: - type: array - items: - type: string - query_type: - type: string - enum: - - simple - - vector - embedding_dependency: - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - required: - - endpoint - - index_name - - authentication - description: The parameter information to control the use of the Elasticsearch data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - MessageObjectAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - MongoDBChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - mongo_db - description: The discriminated type identifier, which is always 'mongo_db'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - endpoint: - type: string - description: The name of the MongoDB cluster endpoint. - database_name: - type: string - description: The name of the MongoDB database. - collection_name: - type: string - description: The name of the MongoDB collection. - app_name: - type: string - description: The name of the MongoDB application. - index_name: - type: string - description: The name of the MongoDB index. - authentication: - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' - description: |- - The authentication mechanism to use with Pinecone. - Supported authentication mechanisms for Pinecone include: username and password. - embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - description: |- - The vectorization source to use as an embedding dependency for the MongoDB data source. - Supported vectorization sources for MongoDB include: endpoint, deployment name. - fields_mapping: - type: object - properties: - content_fields: - type: array - items: - type: string - vector_fields: - type: array - items: - type: string - title_field: - type: string - url_field: - type: string - filepath_field: - type: string - content_fields_separator: - type: string - required: - - content_fields - - vector_fields - description: |- - Field mappings to apply to data used by the MongoDB data source. - Note that content and vector field mappings are required for MongoDB. - required: - - endpoint - - database_name - - collection_name - - app_name - - index_name - - authentication - - embedding_dependency - - fields_mapping - description: The parameter information to control the use of the MongoDB data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - OpenAI.AssistantToolDefinition: - type: object - required: - - type - properties: - type: - type: string - discriminator: - propertyName: type - mapping: - file_search: '#/components/schemas/OpenAI.AssistantToolsFileSearch' - function: '#/components/schemas/OpenAI.AssistantToolsFunction' - OpenAI.AssistantToolsCode: - type: object - required: - - type - properties: - type: - type: string - enum: - - code_interpreter - description: 'The type of tool being defined: `code_interpreter`' - allOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - OpenAI.AssistantToolsFileSearch: - type: object - required: - - type - properties: - type: - type: string - enum: - - file_search - description: 'The type of tool being defined: `file_search`' - file_search: - type: object - properties: - max_num_results: - type: integer - format: int32 - minimum: 1 - maximum: 50 - description: |- - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. - - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. - ranking_options: - $ref: '#/components/schemas/OpenAI.FileSearchRankingOptions' - description: Overrides for the file search tool. - allOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - OpenAI.AssistantToolsFileSearchTypeOnly: - type: object - required: - - type - properties: - type: - type: string - enum: - - file_search - description: 'The type of tool being defined: `file_search`' - OpenAI.AssistantToolsFunction: - type: object - required: - - type - - function - properties: - type: - type: string - enum: - - function - description: 'The type of tool being defined: `function`' - function: - $ref: '#/components/schemas/OpenAI.FunctionObject' - allOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - OpenAI.ChatCompletionFunctionCallOption: - type: object - required: - - name - properties: - name: - type: string - description: The name of the function to call. - description: 'Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.' - OpenAI.ChatCompletionFunctions: - type: object - required: - - name - properties: - description: - type: string - description: A description of what the function does, used by the model to choose when and how to call the function. - name: - type: string - description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - parameters: - $ref: '#/components/schemas/OpenAI.FunctionParameters' - deprecated: true - OpenAI.ChatCompletionMessageToolCall: - type: object - required: - - id - - type - - function - properties: - id: - type: string - description: The ID of the tool call. - type: - type: string - enum: - - function - description: The type of the tool. Currently, only `function` is supported. - function: - type: object - properties: - name: - type: string - description: The name of the function to call. - arguments: - type: string - description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. - required: - - name - - arguments - description: The function that the model called. - OpenAI.ChatCompletionMessageToolCallChunk: - type: object - required: - - index - properties: - index: - type: integer - format: int32 - id: - type: string - description: The ID of the tool call. - type: - type: string - enum: - - function - description: The type of the tool. Currently, only `function` is supported. - function: - type: object - properties: - name: - type: string - description: The name of the function to call. - arguments: - type: string - description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. - OpenAI.ChatCompletionNamedToolChoice: - type: object - required: - - type - - function - properties: - type: - type: string - enum: - - function - description: The type of the tool. Currently, only `function` is supported. - function: - type: object - properties: - name: - type: string - description: The name of the function to call. - required: - - name - description: Specifies a tool the model should use. Use to force the model to call a specific function. - OpenAI.ChatCompletionRequestAssistantMessage: - type: object - required: - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessageContentPart' - nullable: true - description: The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. - x-oaiExpandable: true - refusal: - type: string - nullable: true - description: The refusal message by the assistant. - role: - type: string - enum: - - assistant - description: The role of the messages author, in this case `assistant`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - nullable: true - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestAssistantMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartRefusal' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestFunctionMessage: - type: object - required: - - role - - content - - name - properties: - role: - type: string - enum: - - function - description: The role of the messages author, in this case `function`. - content: - type: string - nullable: true - description: The contents of the function message. - name: - type: string - description: The name of the function to call. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - deprecated: true - OpenAI.ChatCompletionRequestMessage: - type: object - required: - - role - properties: - role: - type: string - description: The role of the author of this message. - discriminator: - propertyName: role - mapping: - system: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessage' - user: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessage' - assistant: '#/components/schemas/OpenAI.ChatCompletionRequestAssistantMessage' - tool: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessage' - function: '#/components/schemas/OpenAI.ChatCompletionRequestFunctionMessage' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestMessageContentPartImage: - type: object - required: - - type - - image_url - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - format: uri - description: Either a URL of the image or the base64 encoded image data. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). - default: auto - required: - - url - OpenAI.ChatCompletionRequestMessageContentPartRefusal: - type: object - required: - - type - - refusal - properties: - type: - type: string - enum: - - refusal - description: The type of the content part. - refusal: - type: string - description: The refusal message generated by the model. - OpenAI.ChatCompletionRequestMessageContentPartText: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: The type of the content part. - text: - type: string - description: The text content. - OpenAI.ChatCompletionRequestSystemMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestSystemMessageContentPart' - description: The contents of the system message. - role: - type: string - enum: - - system - description: The role of the messages author, in this case `system`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestSystemMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestToolMessage: - type: object - required: - - role - - content - - tool_call_id - properties: - role: - type: string - enum: - - tool - description: The role of the messages author, in this case `tool`. - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestToolMessageContentPart' - description: The contents of the tool message. - tool_call_id: - type: string - description: Tool call that this message is responding to. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestToolMessageContentPart: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - OpenAI.ChatCompletionRequestUserMessage: - type: object - required: - - content - - role - properties: - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestUserMessageContentPart' - description: The contents of the user message. - x-oaiExpandable: true - role: - type: string - enum: - - user - description: The role of the messages author, in this case `user`. - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - OpenAI.ChatCompletionRequestUserMessageContentPart: - anyOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartImage' - x-oaiExpandable: true - OpenAI.ChatCompletionResponseMessage: - type: object - required: - - content - - refusal - - role - properties: - content: - type: string - nullable: true - description: The contents of the message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCallsItem' - role: - type: string - enum: - - assistant - description: The role of the author of this message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - required: - - name - - arguments - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - description: A chat completion message generated by the model. - OpenAI.ChatCompletionStreamOptions: - type: object - properties: - include_usage: - type: boolean - description: 'If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.' - description: 'Options for streaming response. Only set this when you set `stream: true`.' - OpenAI.ChatCompletionStreamResponseDelta: - type: object - properties: - content: - type: string - nullable: true - description: The contents of the chunk message. - function_call: - type: object - properties: - name: - type: string - arguments: - type: string - description: Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - deprecated: true - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCallChunk' - role: - type: string - enum: - - system - - user - - assistant - - tool - description: The role of the author of this message. - refusal: - type: string - nullable: true - description: The refusal message generated by the model. - description: A chat completion delta generated by streamed model responses. - OpenAI.ChatCompletionTokenLogprob: - type: object - required: - - token - - logprob - - bytes - - top_logprobs - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - top_logprobs: - type: array - items: - type: object - properties: - token: - type: string - description: The token. - logprob: - type: number - format: float - description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - bytes: - type: array - items: - type: integer - format: int32 - nullable: true - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - required: - - token - - logprob - - bytes - description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. - OpenAI.ChatCompletionTool: - type: object - required: - - type - - function - properties: - type: - type: string - enum: - - function - description: The type of the tool. Currently, only `function` is supported. - function: - $ref: '#/components/schemas/OpenAI.FunctionObject' - OpenAI.ChatCompletionToolChoiceOption: - anyOf: - - type: string - enum: - - none - - auto - - required - - $ref: '#/components/schemas/OpenAI.ChatCompletionNamedToolChoice' - description: |- - Controls which (if any) tool is called by the model. - `none` means the model will not call any tool and instead generates a message. - `auto` means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools. - Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - `none` is the default when no tools are present. `auto` is the default if tools are present. - x-oaiExpandable: true - OpenAI.ChatResponseFormat: - type: object - required: - - type - properties: - type: - type: string - discriminator: - propertyName: type - mapping: - text: '#/components/schemas/OpenAI.ChatResponseFormatText' - json_object: '#/components/schemas/OpenAI.ChatResponseFormatJsonObject' - json_schema: '#/components/schemas/OpenAI.ChatResponseFormatJsonSchema' - OpenAI.ChatResponseFormatJsonObject: - type: object - required: - - type - properties: - type: - type: string - enum: - - json_object - description: 'The type of response format being defined: `json_object`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatJsonSchema: - type: object - required: - - type - - json_schema - properties: - type: - type: string - enum: - - json_schema - description: 'The type of response format being defined: `json_schema`' - json_schema: - type: object - properties: - description: - type: string - description: A description of what the response format is for, used by the model to determine how to respond in the format. - name: - type: string - description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - schema: - $ref: '#/components/schemas/OpenAI.ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). - default: false - required: - - name - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.ChatResponseFormatText: - type: object - required: - - type - properties: - type: - type: string - enum: - - text - description: 'The type of response format being defined: `text`' - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - OpenAI.CompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - format: int32 - description: Number of tokens in the prompt. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens generated by the model. - reasoning_tokens: - type: integer - format: int32 - description: Tokens generated by the model for reasoning. - required: - - audio_tokens - - reasoning_tokens - description: Breakdown of tokens used in a completion. - prompt_tokens_details: - type: object - properties: - audio_tokens: - type: integer - format: int32 - description: Audio input tokens present in the prompt. - cached_tokens: - type: integer - format: int32 - description: Cached tokens present in the prompt. - required: - - audio_tokens - - cached_tokens - description: Breakdown of tokens used in the prompt. - description: Usage statistics for the completion request. - OpenAI.CreateChatCompletionRequest: - type: object - required: - - messages - - model - properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessage' - minItems: 1 - description: A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and audio. - model: - anyOf: - - type: string - - type: string - enum: - - o1-preview - - o1-preview-2024-09-12 - - o1-mini - - o1-mini-2024-09-12 - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - - chatgpt-4o-latest - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0301 - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. - x-oaiTypeLabel: string - store: - type: boolean - nullable: true - description: |- - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - default: false - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - frequency_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - logit_bias: - type: object - additionalProperties: - type: integer - format: int32 - nullable: true - description: |- - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - x-oaiTypeLabel: map - default: null - logprobs: - type: boolean - nullable: true - description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - default: false - top_logprobs: - type: integer - format: int32 - nullable: true - minimum: 0 - maximum: 20 - description: An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. - max_tokens: - type: integer - format: int32 - nullable: true - description: |- - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - deprecated: true - max_completion_tokens: - type: integer - format: int32 - nullable: true - description: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 128 - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - default: 1 - presence_penalty: - type: number - format: float - nullable: true - minimum: -2 - maximum: 2 - description: |- - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - default: 0 - response_format: - allOf: - - $ref: '#/components/schemas/OpenAI.ChatResponseFormat' - description: |- - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - seed: - type: integer - format: int64 - nullable: true - minimum: -9223372036854776000 - maximum: 9223372036854776000 - description: |- - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - service_tier: - type: string - enum: - - auto - - default - nullable: true - description: |- - Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. - default: auto - stop: - anyOf: - - type: string - - type: array - items: - type: string - nullable: true - description: Up to 4 sequences where the API will stop generating further tokens. - default: null - stream: - type: boolean - nullable: true - description: 'If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).' - default: false - stream_options: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionStreamOptions' - nullable: true - default: null - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: |- - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - default: 1 - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTool' - description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - tool_choice: - $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' - parallel_tool_calls: - type: boolean - default: true - user: - type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - function_call: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctionCallOption' - description: |- - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. - deprecated: true - x-oaiExpandable: true - functions: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionFunctions' - minItems: 1 - maxItems: 128 - description: |- - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - deprecated: true - OpenAI.CreateChatCompletionResponse: - type: object - required: - - id - - choices - - created - - model - - object - properties: - id: - type: string - description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - created: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: - type: string - description: The model used for the chat completion. - service_tier: - type: string - enum: - - scale - - default - nullable: true - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - system_fingerprint: - type: string - description: |- - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - enum: - - chat.completion - description: The object type, which is always `chat.completion`. - usage: - $ref: '#/components/schemas/OpenAI.CompletionUsage' - description: Represents a chat completion response returned by model, based on the provided input. - OpenAI.CreateImageRequest: - type: object - required: - - prompt - properties: - prompt: - type: string - description: A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`. - model: - anyOf: - - type: string - - type: string - enum: - - dall-e-2 - - dall-e-3 - nullable: true - description: The model to use for image generation. - x-oaiTypeLabel: string - default: dall-e-2 - n: - type: integer - format: int32 - nullable: true - minimum: 1 - maximum: 10 - description: The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported. - default: 1 - quality: - type: string - enum: - - standard - - hd - description: The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`. - default: standard - response_format: - type: string - enum: - - url - - b64_json - nullable: true - description: The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. - default: url - size: - type: string - enum: - - 256x256 - - 512x512 - - 1024x1024 - - 1792x1024 - - 1024x1792 - nullable: true - description: The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3` models. - default: 1024x1024 - style: - type: string - enum: - - vivid - - natural - nullable: true - description: The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`. - default: vivid - user: - type: string - description: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - OpenAI.CreateMessageRequest: - type: object - required: - - role - - content - properties: - role: - type: string - enum: - - user - - assistant - description: |- - The role of the entity that is creating the message. Allowed values include: - - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. - - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.MessageContent' - x-oaiExpandable: true - attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachments' - nullable: true - description: A list of files attached to the message, and the tools they should be added to. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - x-oaiTypeLabel: map - OpenAI.Error: - type: object - required: - - code - - message - - param - - type - properties: - code: - type: string - nullable: true - message: - type: string - param: - type: string - nullable: true - type: - type: string - OpenAI.ErrorResponse: - type: object - required: - - error - properties: - error: - $ref: '#/components/schemas/OpenAI.Error' - OpenAI.FileSearchRankingOptions: - type: object - required: - - score_threshold - properties: - ranker: - type: string - enum: - - auto - - default_2024_08_21 - description: The ranker to use for the file search. If not specified will use the `auto` ranker. - score_threshold: - type: number - format: float - minimum: 0 - maximum: 1 - description: The score threshold for the file search. All values must be a floating point number between 0 and 1. - description: |- - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. - - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. - OpenAI.FunctionObject: - type: object - required: - - name - properties: - description: - type: string - description: A description of what the function does, used by the model to choose when and how to call the function. - name: - type: string - description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - parameters: - $ref: '#/components/schemas/OpenAI.FunctionParameters' - strict: - type: boolean - nullable: true - description: Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling). - default: false - OpenAI.FunctionParameters: - type: object - additionalProperties: {} - description: |- - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - OpenAI.Image: - type: object - properties: - b64_json: - type: string - format: base64 - description: The base64-encoded JSON of the generated image, if `response_format` is `b64_json`. - url: - type: string - format: uri - description: The URL of the generated image, if `response_format` is `url` (default). - revised_prompt: - type: string - description: The prompt that was used to generate the image, if there was any revision to the prompt. - description: Represents the url or the content of an image generated by the OpenAI API. - OpenAI.ImagesResponse: - type: object - required: - - created - - data - properties: - created: - type: integer - format: unixtime - data: - type: array - items: - $ref: '#/components/schemas/OpenAI.Image' - OpenAI.MessageContent: - type: object - description: Represents a single piece of content in an Assistants API message. - OpenAI.MessageContentImageFileObject: - type: object - required: - - type - - image_file - properties: - type: - type: string - enum: - - image_file - description: Always `image_file`. - image_file: - type: object - properties: - file_id: - type: string - description: The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - default: auto - required: - - file_id - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContent' - description: References an image [File](/docs/api-reference/files) in the content of a message. - OpenAI.MessageContentImageUrlObject: - type: object - required: - - type - - image_url - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - format: uri - description: 'The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.' - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - default: auto - required: - - url - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContent' - description: References an image URL in the content of a message. - OpenAI.MessageContentRefusalObject: - type: object - required: - - type - - refusal - properties: - type: - type: string - enum: - - refusal - description: Always `refusal`. - refusal: - type: string - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContent' - description: The refusal content generated by the assistant. - OpenAI.MessageContentTextAnnotationsFileCitationObject: - type: object - required: - - type - - text - - file_citation - - start_index - - end_index - properties: - type: - type: string - enum: - - file_citation - description: Always `file_citation`. - text: - type: string - description: The text in the message content that needs to be replaced. - file_citation: - type: object - properties: - file_id: - type: string - description: The ID of the specific File the citation is from. - required: - - file_id - start_index: - type: integer - format: int32 - minimum: 0 - end_index: - type: integer - format: int32 - minimum: 0 - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' - description: A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. - OpenAI.MessageContentTextAnnotationsFilePathObject: - type: object - required: - - type - - text - - file_path - - start_index - - end_index - properties: - type: - type: string - enum: - - file_path - description: Always `file_path`. - text: - type: string - description: The text in the message content that needs to be replaced. - file_path: - type: object - properties: - file_id: - type: string - description: The ID of the file that was generated. - required: - - file_id - start_index: - type: integer - format: int32 - minimum: 0 - end_index: - type: integer - format: int32 - minimum: 0 - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' - description: A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - OpenAI.MessageContentTextObject: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: Always `text`. - text: - type: object - properties: - value: - type: string - description: The data that makes up the text. - annotations: - type: array - items: - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' - x-oaiExpandable: true - required: - - value - - annotations - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContent' - description: The text content that is part of a message. - OpenAI.MessageContentTextObjectAnnotation: - type: object - required: - - type - properties: - type: - type: string - description: The discriminated type identifier for the content item. - discriminator: - propertyName: type - mapping: - file_citation: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFileCitationObject' - file_path: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFilePathObject' - OpenAI.MessageObject: - type: object - required: - - id - - object - - created_at - - thread_id - - status - - incomplete_details - - completed_at - - incomplete_at - - role - - content - - assistant_id - - run_id - - attachments - - metadata - properties: - id: - type: string - description: The identifier, which can be referenced in API endpoints. - object: - type: string - enum: - - thread.message - description: The object type, which is always `thread.message`. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the message was created. - thread_id: - type: string - description: The [thread](/docs/api-reference/threads) ID that this message belongs to. - status: - type: string - enum: - - in_progress - - incomplete - - completed - description: The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - incomplete_details: - type: object - properties: - reason: - type: string - enum: - - content_filter - - max_tokens - - run_cancelled - - run_expired - - run_failed - description: The reason the message is incomplete. - required: - - reason - nullable: true - description: On an incomplete message, details about why the message is incomplete. - completed_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the message was completed. - incomplete_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the message was marked as incomplete. - role: - type: string - enum: - - user - - assistant - description: The entity that produced the message. One of `user` or `assistant`. - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.MessageContent' - description: The content of the message in array of text and/or images. - x-oaiExpandable: true - assistant_id: - type: string - nullable: true - description: If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - run_id: - type: string - nullable: true - description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachments' - nullable: true - description: A list of files attached to the message, and the tools they were added to. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - x-oaiTypeLabel: map - description: Represents a message within a [thread](/docs/api-reference/threads). - OpenAI.MessageRequestContentTextObject: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: Always `text`. - text: - type: string - description: Text content to be sent to the model - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContent' - description: The text content that is part of a message. - OpenAI.ResponseFormatJsonSchemaSchema: - type: object - additionalProperties: {} - description: The schema for the response format, described as a JSON Schema object. - OpenAIFileWithOmittedProperties: - type: object - required: - - id - - bytes - - created_at - - filename - - object - - purpose - properties: - id: - type: string - description: The file identifier, which can be referenced in the API endpoints. - bytes: - type: integer - format: int32 - nullable: true - description: The size of the file, in bytes. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - enum: - - file - description: The object type, which is always `file`. - purpose: - type: string - enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - status_details: - type: string - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. - deprecated: true - description: The `File` object represents a document that has been uploaded to OpenAI. - PineconeChatDataSource: - type: object - required: - - type - - parameters - properties: - type: - type: string - enum: - - pinecone - description: The discriminated type identifier, which is always 'pinecone'. - parameters: - type: object - properties: - top_n_documents: - type: integer - format: int32 - description: The configured number of documents to feature in the query. - in_scope: - type: boolean - description: Whether queries should be restricted to use of the indexed data. - strictness: - type: integer - format: int32 - minimum: 1 - maximum: 5 - description: |- - The configured strictness of the search relevance filtering. - Higher strictness will increase precision but lower recall of the answer. - max_search_queries: - type: integer - format: int32 - description: |- - The maximum number of rewritten queries that should be sent to the search provider for a single user message. - By default, the system will make an automatic determination. - allow_partial_result: - type: boolean - description: |- - If set to true, the system will allow partial search results to be used and the request will fail if all - partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - default: false - include_contexts: - type: array - items: - type: string - enum: - - citations - - intent - - all_retrieved_documents - maxItems: 3 - description: |- - The output context properties to include on the response. - By default, citations and intent will be requested. - default: - - citations - - intent - environment: - type: string - description: The environment name to use with Pinecone. - index_name: - type: string - description: The name of the Pinecone database index to use. - authentication: - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceApiKeyAuthenticationOptions' - description: |- - The authentication mechanism to use with Pinecone. - Supported authentication mechanisms for Pinecone include: API key. - embedding_dependency: - allOf: - - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' - description: |- - The vectorization source to use as an embedding dependency for the Pinecone data source. - Supported vectorization sources for Pinecone include: deployment name. - fields_mapping: - type: object - properties: - content_fields: - type: array - items: - type: string - title_field: - type: string - url_field: - type: string - filepath_field: - type: string - content_fields_separator: - type: string - required: - - content_fields - description: |- - Field mappings to apply to data used by the Pinecone data source. - Note that content field mappings are required for Pinecone. - required: - - environment - - index_name - - authentication - - embedding_dependency - - fields_mapping - description: The parameter information to control the use of the Pinecone data source. - allOf: - - $ref: '#/components/schemas/AzureChatDataSource' - securitySchemes: - ApiKeyAuth: - type: apiKey - in: header - name: api-key - OAuth2Auth: - type: oauth2 - flows: - implicit: - authorizationUrl: https://login.microsoftonline.com/common/oauth2/v2.0/authorize - scopes: - https://cognitiveservices.azure.com/.default: '' -servers: - - url: '{endpoint}/openai' - description: Azure OpenAI APIs for completions and search - variables: - endpoint: - default: '' - description: |- - Supported Cognitive Services endpoints (protocol and hostname, for example: - https://westus.api.cognitive.microsoft.com). diff --git a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml index ccbb1c975..4ec5f7276 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml @@ -203,13 +203,13 @@ components: discriminator: propertyName: type mapping: - username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' AzureChatDataSourceConnectionStringAuthenticationOptions: type: object required: @@ -404,6 +404,7 @@ components: discriminator: propertyName: type mapping: + endpoint: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' @@ -1363,10 +1364,8 @@ components: type: string description: A filter to apply to the search. embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' description: |- The vectorization source to use with Azure Search. Supported sources for Azure Search include endpoint, deployment name, and integrated. diff --git a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml index 1df9d1f44..3bde50a71 100644 --- a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml @@ -203,13 +203,13 @@ components: discriminator: propertyName: type mapping: - username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' connection_string: '#/components/schemas/AzureChatDataSourceConnectionStringAuthenticationOptions' + system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' + user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' key_and_key_id: '#/components/schemas/AzureChatDataSourceKeyAndKeyIdAuthenticationOptions' encoded_api_key: '#/components/schemas/AzureChatDataSourceEncodedApiKeyAuthenticationOptions' access_token: '#/components/schemas/AzureChatDataSourceAccessTokenAuthenticationOptions' - system_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions' - user_assigned_managed_identity: '#/components/schemas/AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions' + username_and_password: '#/components/schemas/AzureChatDataSourceUsernameAndPasswordAuthenticationOptions' AzureChatDataSourceConnectionStringAuthenticationOptions: type: object required: @@ -404,6 +404,7 @@ components: discriminator: propertyName: type mapping: + endpoint: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' deployment_name: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' model_id: '#/components/schemas/AzureChatDataSourceModelIdVectorizationSource' integrated: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' @@ -1413,10 +1414,8 @@ components: type: string description: A filter to apply to the search. embedding_dependency: - anyOf: - - $ref: '#/components/schemas/AzureChatDataSourceEndpointVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceDeploymentNameVectorizationSource' - - $ref: '#/components/schemas/AzureChatDataSourceIntegratedVectorizationSource' + allOf: + - $ref: '#/components/schemas/AzureChatDataSourceVectorizationSource' description: |- The vectorization source to use with Azure Search. Supported sources for Azure Search include endpoint, deployment name, and integrated. diff --git a/.typespec.azure/chat/models.oyd.auth.tsp b/.typespec.azure/chat/models.oyd.auth.tsp index 9e2b85cdc..5e0f05138 100644 --- a/.typespec.azure/chat/models.oyd.auth.tsp +++ b/.typespec.azure/chat/models.oyd.auth.tsp @@ -16,20 +16,26 @@ model AzureChatDataSourceApiKeyAuthenticationOptions key: string; } -@added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) -model AzureChatDataSourceUsernameAndPasswordAuthenticationOptions - extends AzureChatDataSourceAuthenticationOptions { - type: "username_and_password"; - username: string; - password: string; -} - model AzureChatDataSourceConnectionStringAuthenticationOptions extends AzureChatDataSourceAuthenticationOptions { type: "connection_string"; connection_string: string; } +model AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions + extends AzureChatDataSourceAuthenticationOptions { + type: "system_assigned_managed_identity"; +} + +model AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions + extends AzureChatDataSourceAuthenticationOptions { + type: "user_assigned_managed_identity"; + managed_identity_resource_id: string; +} + +@added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) // from 2024-07-01-preview +@removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model AzureChatDataSourceKeyAndKeyIdAuthenticationOptions extends AzureChatDataSourceAuthenticationOptions { type: "key_and_key_id"; @@ -37,25 +43,30 @@ model AzureChatDataSourceKeyAndKeyIdAuthenticationOptions key_id: string; } +@added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) // from 2024-07-01-preview +@removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model AzureChatDataSourceEncodedApiKeyAuthenticationOptions extends AzureChatDataSourceAuthenticationOptions { type: "encoded_api_key"; encoded_api_key: string; } +@added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) // from 2024-07-01-preview +@removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model AzureChatDataSourceAccessTokenAuthenticationOptions extends AzureChatDataSourceAuthenticationOptions { type: "access_token"; access_token: string; } -model AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions - extends AzureChatDataSourceAuthenticationOptions { - type: "system_assigned_managed_identity"; -} - -model AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions +@added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) +@removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) +model AzureChatDataSourceUsernameAndPasswordAuthenticationOptions extends AzureChatDataSourceAuthenticationOptions { - type: "user_assigned_managed_identity"; - managed_identity_resource_id: string; + type: "username_and_password"; + username: string; + password: string; } diff --git a/.typespec.azure/chat/models.oyd.vectorization.tsp b/.typespec.azure/chat/models.oyd.vectorization.tsp index 843aa9444..b35529255 100644 --- a/.typespec.azure/chat/models.oyd.vectorization.tsp +++ b/.typespec.azure/chat/models.oyd.vectorization.tsp @@ -35,6 +35,10 @@ model AzureChatDataSourceEndpointVectorizationSource * The authentication mechanism to use with the endpoint-based vectorization source. * Endpoint authentication supports API key and access token mechanisms. */ + @typeChangedFrom( + AzureOpenAIServiceApiVersion.v2024_10_21, + AzureChatDataSourceApiKeyAuthenticationOptions + ) authentication: AzureChatDataSourceApiKeyAuthenticationOptions | AzureChatDataSourceAccessTokenAuthenticationOptions; /** @@ -71,6 +75,9 @@ model AzureChatDataSourceDeploymentNameVectorizationSource * Represents a vectorization source that makes service calls based on a search service model ID. * This source type is currently only supported by Elasticsearch. */ +@added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) +@removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model AzureChatDataSourceModelIdVectorizationSource extends AzureChatDataSourceVectorizationSource { /** The type identifier, always 'model_id' for this vectorization source type. */ @@ -84,6 +91,8 @@ model AzureChatDataSourceModelIdVectorizationSource * Represents an integrated vectorization source as defined within the supporting search resource. */ @added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) +@removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model AzureChatDataSourceIntegratedVectorizationSource extends AzureChatDataSourceVectorizationSource { /** The type identifier, always 'integrated' for this vectorization source type. */ diff --git a/.typespec.azure/chat/models.request.tsp b/.typespec.azure/chat/models.request.tsp index c154b9eec..0ae2aeba3 100644 --- a/.typespec.azure/chat/models.request.tsp +++ b/.typespec.azure/chat/models.request.tsp @@ -58,9 +58,6 @@ model CreateChatCompletionRequestCommonBase @@added(CreateChatCompletionRequestCommonBase.parallel_tool_calls, AzureOpenAIServiceApiVersion.v2024_09_01_preview ); -@@added(OpenAI.CompletionUsage.completion_tokens_details, - AzureOpenAIServiceApiVersion.v2024_09_01_preview -); // Ingested changes from OpenAI for 2024-08-01-preview @@ -73,9 +70,12 @@ model CreateChatCompletionRequestCommonBase string ); -// Ingested changes from OpenAI for 2024-07-01-preview +// Ingested changes from OpenAI for 2024-07-01-preview (moved to 2024-08-01-preview) -// @@added(OpenAI.ChatCompletionToolChoiceOption.required, AzureOpenAIServiceApiVersion.v2024_07_01_preview); +@@typeChangedFrom(CreateChatCompletionRequestCommonBase.tool_choice, + AzureOpenAIServiceApiVersion.v2024_08_01_preview, + "none" | "auto" | OpenAI.ChatCompletionNamedToolChoice +); /** * The extended request model for chat completions against the Azure OpenAI service. @@ -105,6 +105,10 @@ model AzureChatDataSource { type: string; } +alias AzureSearchAuthenticationOptions = AzureChatDataSourceApiKeyAuthenticationOptions | AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions | AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions; + +alias AzureSearchAuthenticationOptionsWithAccessToken = AzureSearchAuthenticationOptions | AzureChatDataSourceAccessTokenAuthenticationOptions; + /** Represents a data source configuration that will use an Azure Search resource. */ model AzureSearchChatDataSource extends AzureChatDataSource { /** The discriminated type identifier, which is always 'azure_search'. */ @@ -123,11 +127,11 @@ model AzureSearchChatDataSource extends AzureChatDataSource { /** * The authentication mechanism to use with Azure Search. */ - authentication: - | AzureChatDataSourceApiKeyAuthenticationOptions - | AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions - | AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions - | AzureChatDataSourceAccessTokenAuthenticationOptions; + @typeChangedFrom( + AzureOpenAIServiceApiVersion.v2024_10_21, + AzureSearchAuthenticationOptions + ) + authentication: AzureSearchAuthenticationOptionsWithAccessToken; /** The field mappings to use with the Azure Search resource. */ fields_mapping?: { @@ -171,36 +175,7 @@ model AzureSearchChatDataSource extends AzureChatDataSource { * The vectorization source to use with Azure Search. * Supported sources for Azure Search include endpoint, deployment name, and integrated. */ - @typeChangedFrom( - AzureOpenAIServiceApiVersion.v2024_08_01_preview, - AzureChatDataSourceEndpointVectorizationSource | AzureChatDataSourceDeploymentNameVectorizationSource - ) - embedding_dependency?: AzureChatDataSourceEndpointVectorizationSource | AzureChatDataSourceDeploymentNameVectorizationSource | AzureChatDataSourceIntegratedVectorizationSource; - }; -} - -/** Represents a data source configuration that will use an Azure Machine Learning vector index. */ -@removed(AzureOpenAIServiceApiVersion.v2024_08_01_preview) -model AzureMachineLearningIndexChatDataSource extends AzureChatDataSource { - /** The discriminated type identifier, which is always 'azure_ml_index'. */ - type: "azure_ml_index"; - - /** The parameter information to control the use of the Azure Machine Learning Index data source. */ - parameters: { - ...AzureChatDataSourceCommonParameters; - authentication: AzureChatDataSourceAccessTokenAuthenticationOptions | AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions | AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions; - - /** The ID of the Azure Machine Learning index project to use. */ - project_resource_id: string; - - /** The name of the Azure Machine Learning index to use. */ - name: string; - - /** The version of the vector index to use. */ - version: string; - - /** A search filter, which is only applicable if the vector index is of the 'AzureSearch' type. */ - filter?: string; + embedding_dependency?: AzureChatDataSourceVectorizationSource; }; } @@ -228,6 +203,9 @@ model AzureCosmosDBChatDataSource extends AzureChatDataSource { }; } +@added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) // from 2024-07-01-preview +@removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model ElasticsearchChatDataSource extends AzureChatDataSource { /** The discriminated type identifier, which is always 'elasticsearch'. */ type: "elasticsearch"; @@ -237,7 +215,12 @@ model ElasticsearchChatDataSource extends AzureChatDataSource { ...AzureChatDataSourceCommonParameters; endpoint: url; index_name: string; + + @added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) // from 2024-07-01-preview + @removed(AzureOpenAIServiceApiVersion.v2024_10_21) + @added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) authentication: AzureChatDataSourceKeyAndKeyIdAuthenticationOptions | AzureChatDataSourceEncodedApiKeyAuthenticationOptions; + fields_mapping?: { title_field?: string; url_field?: string; @@ -251,6 +234,9 @@ model ElasticsearchChatDataSource extends AzureChatDataSource { }; } +@added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) // from 2024-07-01-preview +@removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model PineconeChatDataSource extends AzureChatDataSource { /** The discriminated type identifier, which is always 'pinecone'. */ type: "pinecone"; @@ -292,6 +278,8 @@ model PineconeChatDataSource extends AzureChatDataSource { } @added(AzureOpenAIServiceApiVersion.v2024_08_01_preview) +@removed(AzureOpenAIServiceApiVersion.v2024_10_21) +@added(AzureOpenAIServiceApiVersion.v2024_12_01_preview) model MongoDBChatDataSource extends AzureChatDataSource { /** The discriminated type identifier, which is always 'mongo_db'. */ type: "mongo_db"; diff --git a/.typespec.azure/chat/models.response.tsp b/.typespec.azure/chat/models.response.tsp index 5d0e203ce..79db7e221 100644 --- a/.typespec.azure/chat/models.response.tsp +++ b/.typespec.azure/chat/models.response.tsp @@ -1,8 +1,24 @@ +import "@typespec/versioning"; + import "../../.typespec/chat/models.tsp"; import "../common"; +using TypeSpec.Versioning; + namespace AzureOpenAI; +// Ingested changes from OpenAI for 2024-09-01-preview + +@@added(OpenAI.CompletionUsage.completion_tokens_details, + AzureOpenAIServiceApiVersion.v2024_09_01_preview +); + +// Ingested changes from OpenAI for 2024-08-01-preview + +@@added(OpenAI.ChatResponseFormatJsonSchema, + AzureOpenAIServiceApiVersion.v2024_08_01_preview +); + /** * The extended top-level chat completion response model for the Azure OpenAI service. * This model adds Responsible AI content filter annotations for prompt input. From 55595204f9ffdcfee80bd0433036068934af795c Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 23 Jan 2025 17:43:17 -0800 Subject: [PATCH 25/44] scenario-specific default versioning affordance, test cleanup --- .../sdk/openai/Azure.AI.OpenAI/assets.json | 2 +- .../Custom/Assistants/AzureAssistantClient.cs | 2 +- .../src/Custom/Audio/AzureAudioClient.cs | 2 +- .../src/Custom/AzureOpenAIClientOptions.cs | 89 +++++++++++++++---- .../src/Custom/Batch/AzureBatchClient.cs | 2 +- .../src/Custom/Chat/AzureChatClient.cs | 2 +- .../Custom/Embeddings/AzureEmbeddingClient.cs | 2 +- .../src/Custom/Files/AzureFileClient.cs | 2 +- .../FineTuning/AzureFineTuningClient.cs | 2 +- .../src/Custom/Images/AzureImageClient.cs | 2 +- .../AzureRealtimeConversationClient.cs | 11 ++- .../VectorStores/AzureVectorStoreClient.cs | 2 +- .../tests/Assets/playback_test_config.json | 5 ++ .../Azure.AI.OpenAI/tests/ChatTests.Audio.cs | 3 +- .../tests/ConversationTestFixtureBase.cs | 4 - .../tests/ConversationTests.cs | 25 +++--- .../openai/Azure.AI.OpenAI/tests/FileTests.cs | 10 +-- .../Azure.AI.OpenAI/tests/FineTuningTests.cs | 4 - 18 files changed, 109 insertions(+), 62 deletions(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json index 104c90a37..948b246cb 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "dotnet.azure/openai/Azure.AI.OpenAI", - "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_a86178ecf1" + "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_b997d3175c" } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Assistants/AzureAssistantClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Assistants/AzureAssistantClient.cs index 4696958ed..9d393f854 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Assistants/AzureAssistantClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Assistants/AzureAssistantClient.cs @@ -26,7 +26,7 @@ internal AzureAssistantClient(ClientPipeline pipeline, Uri endpoint, AzureOpenAI options ??= new(); _endpoint = endpoint; - _apiVersion = options.Version; + _apiVersion = options.GetRawServiceApiValueForClient(this); } protected AzureAssistantClient() diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Audio/AzureAudioClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Audio/AzureAudioClient.cs index f15480951..800e968e7 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Audio/AzureAudioClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Audio/AzureAudioClient.cs @@ -28,7 +28,7 @@ internal AzureAudioClient(ClientPipeline pipeline, string deploymentName, Uri en _deploymentName = deploymentName; _endpoint = endpoint; - _apiVersion = options.Version; + _apiVersion = options.GetRawServiceApiValueForClient(this); } protected AzureAudioClient() diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs index b2eedd95f..befca3770 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs @@ -1,16 +1,20 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Azure.AI.OpenAI.Files; +using Azure.AI.OpenAI.RealtimeConversation; using System.ClientModel.Primitives; namespace Azure.AI.OpenAI; +#pragma warning disable AOAI001 + /// /// Defines the scenario-independent, client-level options for the Azure-specific OpenAI client. /// public partial class AzureOpenAIClientOptions : ClientPipelineOptions { - internal string Version { get; } + internal ServiceVersion? ExplicitVersion { get; } /// /// The authorization audience to use when authenticating with Azure authentication tokens @@ -45,29 +49,33 @@ public string UserAgentApplicationId private string _userAgentApplicationId; /// - /// Initializes a new instance of + /// Initializes a new instance of . /// - /// The service API version to use with the client. - /// The provided service API version is not supported. - public AzureOpenAIClientOptions(ServiceVersion version = LatestVersion) + /// + /// When using this constructor, the best matching service API version will automatically be selected. This is + /// typically the latest service API version available when the library is published. To specify a service API + /// version manually, use the overload, instead. + /// + public AzureOpenAIClientOptions() : base() { - Version = version switch - { -#if !AZURE_OPENAI_GA - ServiceVersion.V2024_08_01_Preview => "2024-08-01-preview", - ServiceVersion.V2024_09_01_Preview => "2024-09-01-preview", - ServiceVersion.V2024_10_01_Preview => "2024-10-01-preview", - ServiceVersion.V2024_12_01_Preview => "2024-12-01-preview", - ServiceVersion.V2025_01_01_Preview => "2025-01-01-preview", -#endif - ServiceVersion.V2024_06_01 => "2024-06-01", - ServiceVersion.V2024_10_21 => "2024-10-21", - _ => throw new NotSupportedException() - }; RetryPolicy = new RetryWithDelaysPolicy(); } + /// + /// Initializes a new instance of . + /// + /// + /// This overload will attempt to use a specific service API version label that may differ from the preferred + /// default. Please note that operation behavior may differ when using non-default service API versions. + /// + /// The service API version to use with the client. + public AzureOpenAIClientOptions(ServiceVersion version) + : this() + { + ExplicitVersion = version; + } + /// The version of the service to use. public enum ServiceVersion { @@ -84,6 +92,51 @@ public enum ServiceVersion #endif } + private static string GetStringForVersion(ServiceVersion version) + { + return version switch + { + ServiceVersion.V2024_06_01 => "2024-06-01", +#if !AZURE_OPENAI_GA + ServiceVersion.V2024_08_01_Preview => "2024-08-01-preview", + ServiceVersion.V2024_09_01_Preview => "2024-09-01-preview", + ServiceVersion.V2024_10_01_Preview => "2024-10-01-preview", +#endif + ServiceVersion.V2024_10_21 => "2024-10-21", +#if !AZURE_OPENAI_GA + ServiceVersion.V2024_12_01_Preview => "2024-12-01-preview", + ServiceVersion.V2025_01_01_Preview => "2025-01-01-preview", +#endif + _ => throw new NotSupportedException($"The specified {nameof(ServiceVersion)} value ({version}) is not supported.") + }; + } + + internal string GetRawServiceApiValueForClient(object client) + { + if (ExplicitVersion.HasValue) + { + return GetStringForVersion(ExplicitVersion.Value); + } + else + { + ServiceVersion defaultVersion = client switch + { +#if !AZURE_OPENAI_GA + AzureFileClient _ => ServiceVersion.V2024_10_01_Preview, + AzureRealtimeConversationClient _ => ServiceVersion.V2024_10_01_Preview, +#endif +#if !AZURE_OPENAI_GA + // Standard default for beta libraries: latest preview version + _ => ServiceVersion.V2025_01_01_Preview, +#else + // Standard default for GA libraries: latest stable version + _ => ServiceVersion.V2024_10_21, +#endif + }; + return GetStringForVersion(defaultVersion); + } + } + internal class RetryWithDelaysPolicy : ClientRetryPolicy { protected override TimeSpan GetNextDelay(PipelineMessage message, int tryCount) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.cs index 30152ed88..b22f93371 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.cs @@ -27,7 +27,7 @@ internal AzureBatchClient(ClientPipeline pipeline, Uri endpoint, AzureOpenAIClie options ??= new(); _endpoint = endpoint; - _apiVersion = options.Version; + _apiVersion = options.GetRawServiceApiValueForClient(this); } protected AzureBatchClient() diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs index 7d5c692ab..948e7bbe2 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs @@ -35,7 +35,7 @@ internal AzureChatClient(ClientPipeline pipeline, string deploymentName, Uri end _deploymentName = deploymentName; _endpoint = endpoint; - _apiVersion = options.Version; + _apiVersion = options.GetRawServiceApiValueForClient(this); } protected AzureChatClient() diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Embeddings/AzureEmbeddingClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Embeddings/AzureEmbeddingClient.cs index 7bbdf2477..aff514f49 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Embeddings/AzureEmbeddingClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Embeddings/AzureEmbeddingClient.cs @@ -28,7 +28,7 @@ internal AzureEmbeddingClient(ClientPipeline pipeline, string deploymentName, Ur _deploymentName = deploymentName; _endpoint = endpoint; - _apiVersion = options.Version; + _apiVersion = options.GetRawServiceApiValueForClient(this); } protected AzureEmbeddingClient() diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.cs index c50add3b1..5948dbd4f 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.cs @@ -29,7 +29,7 @@ internal AzureFileClient(ClientPipeline pipeline, Uri endpoint, AzureOpenAIClien options ??= new(); _endpoint = endpoint; - _apiVersion = options.Version; + _apiVersion = options.GetRawServiceApiValueForClient(this); } protected AzureFileClient() diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/FineTuning/AzureFineTuningClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/FineTuning/AzureFineTuningClient.cs index 1ca9ae245..bb2acc208 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/FineTuning/AzureFineTuningClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/FineTuning/AzureFineTuningClient.cs @@ -27,7 +27,7 @@ internal AzureFineTuningClient(ClientPipeline pipeline, Uri endpoint, AzureOpenA options ??= new(); _endpoint = endpoint; - _apiVersion = options.Version; + _apiVersion = options.GetRawServiceApiValueForClient(this); } protected AzureFineTuningClient() diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Images/AzureImageClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Images/AzureImageClient.cs index ebeda9dae..e6adea35f 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Images/AzureImageClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Images/AzureImageClient.cs @@ -28,7 +28,7 @@ internal AzureImageClient(ClientPipeline pipeline, string deploymentName, Uri en _deploymentName = deploymentName; _endpoint = endpoint; - _apiVersion = options.Version; + _apiVersion = options.GetRawServiceApiValueForClient(this); } protected AzureImageClient() diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/RealtimeConversation/AzureRealtimeConversationClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/RealtimeConversation/AzureRealtimeConversationClient.cs index ba5fc3608..dfc8b8891 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/RealtimeConversation/AzureRealtimeConversationClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/RealtimeConversation/AzureRealtimeConversationClient.cs @@ -4,7 +4,6 @@ #if !AZURE_OPENAI_GA using Azure.Core; -using OpenAI.RealtimeConversation; using System.ClientModel; namespace Azure.AI.OpenAI.RealtimeConversation; @@ -27,7 +26,10 @@ public AzureRealtimeConversationClient(Uri endpoint, string deploymentName, ApiK : base(deploymentName, credential, new OpenAIClientOptions() { Endpoint = endpoint }) { options ??= new(); - _endpoint = GetEndpoint(endpoint, deploymentName, options.Version); + _endpoint = GetEndpoint( + endpoint, + deploymentName, + options.GetRawServiceApiValueForClient(this)); _credential = credential; Core.TelemetryDetails telemetryDetails = new(typeof(AzureOpenAIClient).Assembly, options?.UserAgentApplicationId); _userAgent = telemetryDetails.ToString(); @@ -37,7 +39,10 @@ public AzureRealtimeConversationClient(Uri endpoint, string deploymentName, Toke : base(deploymentName, credential: new("placeholder") , new OpenAIClientOptions() { Endpoint = endpoint }) { options ??= new(); - _endpoint = GetEndpoint(endpoint, deploymentName, options.Version); + _endpoint = GetEndpoint( + endpoint, + deploymentName, + options.GetRawServiceApiValueForClient(this)); _tokenCredential = credential; _tokenAuthorizationScopes = [options?.Audience?.ToString() ?? AzureOpenAIAudience.AzurePublicCloud.ToString()]; Core.TelemetryDetails telemetryDetails = new(typeof(AzureOpenAIClient).Assembly, options?.UserAgentApplicationId); diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.cs index de9e8664e..1e07b8803 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.cs @@ -29,7 +29,7 @@ internal AzureVectorStoreClient(ClientPipeline pipeline, Uri endpoint, AzureOpen options ??= new(); _endpoint = endpoint; - _apiVersion = options.Version; + _apiVersion = options.GetRawServiceApiValueForClient(this); } protected AzureVectorStoreClient() diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json index 0b30db078..7da461615 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json @@ -24,6 +24,11 @@ "key": "Sanitized", "deployment": "gpt-4o-0806" }, + "chat_audio": { + "endpoint": "https://Sanitized.openai.azure.com/", + "key": "Sanitized", + "deployment": "gpt-4o-audio-preview" + }, "chat_audio_tip": { "endpoint": "https://Sanitized.openai.azure.com/", "key": "Sanitized", diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Audio.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Audio.cs index f58b67fab..d1dcfd9b4 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Audio.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Audio.cs @@ -17,11 +17,10 @@ namespace Azure.AI.OpenAI.Tests; public partial class ChatTests { - [RecordedTest] public async Task ChatAudioWorks() { - ChatClient client = GetTestClient("chat_audio_tip"); + ChatClient client = GetTestClient("chat_audio"); // Part 1a: exercise non-streaming request for text & audio via a user message with (input) audio content diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs index faa4b2e99..86042d699 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTestFixtureBase.cs @@ -42,10 +42,6 @@ public ConversationTestFixtureBase(bool isAsync) public TestClientOptions GetTestClientOptions(AzureOpenAIClientOptions.ServiceVersion? version) { - if (version != AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview) - { - Assert.Inconclusive("/realtime not yet supported outside of 2024-10-01-preview"); - } return version is null ? new TestClientOptions() : new TestClientOptions(version.Value); } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs index dc3602247..c5a83a276 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs @@ -18,14 +18,13 @@ namespace Azure.AI.OpenAI.Tests; [TestFixture(false)] public class ConversationTests : ConversationTestFixtureBase { - public ConversationTests(bool isAsync) : base(isAsync) { } #if !AZURE_OPENAI_GA [Test] [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] [TestCase(null)] public async Task CanConfigureSession(AzureOpenAIClientOptions.ServiceVersion? version) { @@ -98,7 +97,7 @@ List GetReceivedUpdates() where T : ConversationUpdate [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] - //[TestCase(null)] + [TestCase(null)] public async Task TextOnlyWorks(AzureOpenAIClientOptions.ServiceVersion? version) { RealtimeConversationClient client = GetTestClient(GetTestClientOptions(version)); @@ -178,8 +177,8 @@ await session.AddItemAsync( [Test] [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] [TestCase(null)] public async Task ItemManipulationWorks(AzureOpenAIClientOptions.ServiceVersion? version) { @@ -257,8 +256,8 @@ await session.AddItemAsync( [Test] [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] [TestCase(null)] public async Task AudioWithToolsWorks(AzureOpenAIClientOptions.ServiceVersion? version) { @@ -359,8 +358,8 @@ public async Task AudioWithToolsWorks(AzureOpenAIClientOptions.ServiceVersion? v [Test] [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] [TestCase(null)] public async Task CanDisableVoiceActivityDetection(AzureOpenAIClientOptions.ServiceVersion? version) { @@ -414,7 +413,7 @@ or ConversationResponseStartedUpdate [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] - //[TestCase(null)] + [TestCase(null)] public async Task CanUseManualVadTurnDetection(AzureOpenAIClientOptions.ServiceVersion? version) { RealtimeConversationClient client = GetTestClient(GetTestClientOptions(version)); @@ -489,8 +488,8 @@ await session.ConfigureSessionAsync( [Test] [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] [TestCase(null)] public async Task BadCommandProvidesError(AzureOpenAIClientOptions.ServiceVersion? version) { diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs index 2d80dd13f..03f46e867 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs @@ -26,7 +26,7 @@ public FileTests(bool isAsync) : base(isAsync) #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif - //[TestCase(null)] + [TestCase(null)] public async Task CanUploadAndDeleteFiles(AzureOpenAIClientOptions.ServiceVersion? version) { OpenAIFileClient client = GetTestClient(GetTestClientOptions(version)); @@ -48,7 +48,7 @@ public async Task CanUploadAndDeleteFiles(AzureOpenAIClientOptions.ServiceVersio #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif - //[TestCase(null)] + [TestCase(null)] public async Task CanListFiles(AzureOpenAIClientOptions.ServiceVersion? version) { OpenAIFileClient client = GetTestClient(GetTestClientOptions(version)); @@ -58,12 +58,6 @@ public async Task CanListFiles(AzureOpenAIClientOptions.ServiceVersion? version) private static TestClientOptions GetTestClientOptions(AzureOpenAIClientOptions.ServiceVersion? version) { -#if !AZURE_OPENAI_GA - if (version != AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview) - { - Assert.Inconclusive("full /files support not yet available after 2024-10-01-preview"); - } -#endif return version is null ? new TestClientOptions() : new TestClientOptions(version.Value); } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs index e97b4b882..7830ebab8 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs @@ -29,10 +29,6 @@ public class FineTuningTests : AoaiTestBase { public FineTuningTests(bool isAsync) : base(isAsync) { - if (new AzureOpenAIClientOptions().Version == "2024-12-01-preview") - { - Assert.Inconclusive("2024-12-01-preview not currently supported for files, fine-tuning, and related routes"); - } } #if !AZURE_OPENAI_GA From bd1372381ed461703021f1a9ec05189fc64a1247 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 23 Jan 2025 17:51:46 -0800 Subject: [PATCH 26/44] re-push assets; unclear why it didn't flush before, but it should work now --- .dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json index 948b246cb..a1d970592 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "dotnet.azure/openai/Azure.AI.OpenAI", - "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_b997d3175c" + "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_9a2aa7b69d" } From b93a2d0f18d41b63f736a5bb9736bf58e36062ff Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Fri, 24 Jan 2025 16:36:33 -0800 Subject: [PATCH 27/44] no code change: update for spec docs preservation on extended scalar type 'ParallelToolCalls' --- ...e-openai-2024-09-01-preview-generated.yaml | 6 +++++- ...e-openai-2024-10-01-preview-generated.yaml | 6 +++++- ...pi3-azure-openai-2024-10-21-generated.yaml | 6 +++++- ...e-openai-2024-12-01-preview-generated.yaml | 6 +++++- ...e-openai-2025-01-01-preview-generated.yaml | 6 +++++- .openapi3/openapi3-openai.yaml | 21 +++++++++++++------ .typespec/common/models.tsp | 2 +- README.md | 4 ++-- 8 files changed, 43 insertions(+), 14 deletions(-) diff --git a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml index 09e834bfb..208b654cb 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml @@ -965,7 +965,8 @@ components: tool_choice: $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/OpenAI.ParallelToolCalls' default: true user: type: string @@ -2844,6 +2845,9 @@ components: allOf: - $ref: '#/components/schemas/OpenAI.MessageContent' description: The text content that is part of a message. + OpenAI.ParallelToolCalls: + type: boolean + description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. OpenAI.ResponseFormatJsonSchemaSchema: type: object additionalProperties: {} diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml index 4642a176b..268a57d76 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml @@ -965,7 +965,8 @@ components: tool_choice: $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/OpenAI.ParallelToolCalls' default: true user: type: string @@ -2856,6 +2857,9 @@ components: allOf: - $ref: '#/components/schemas/OpenAI.MessageContent' description: The text content that is part of a message. + OpenAI.ParallelToolCalls: + type: boolean + description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. OpenAI.ResponseFormatJsonSchemaSchema: type: object additionalProperties: {} diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml index 6887a8d56..d2366ca7d 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml @@ -862,7 +862,8 @@ components: tool_choice: $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/OpenAI.ParallelToolCalls' default: true user: type: string @@ -2534,6 +2535,9 @@ components: allOf: - $ref: '#/components/schemas/OpenAI.MessageContent' description: The text content that is part of a message. + OpenAI.ParallelToolCalls: + type: boolean + description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. OpenAI.ResponseFormatJsonSchemaSchema: type: object additionalProperties: {} diff --git a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml index 4ec5f7276..73ea16ab7 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml @@ -997,7 +997,8 @@ components: tool_choice: $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/OpenAI.ParallelToolCalls' default: true user: type: string @@ -2935,6 +2936,9 @@ components: allOf: - $ref: '#/components/schemas/OpenAI.MessageContent' description: The text content that is part of a message. + OpenAI.ParallelToolCalls: + type: boolean + description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. OpenAI.ResponseFormatJsonSchemaSchema: type: object additionalProperties: {} diff --git a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml index 3bde50a71..ac93169f9 100644 --- a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml @@ -1047,7 +1047,8 @@ components: tool_choice: $ref: '#/components/schemas/OpenAI.ChatCompletionToolChoiceOption' parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/OpenAI.ParallelToolCalls' default: true user: type: string @@ -3003,6 +3004,9 @@ components: allOf: - $ref: '#/components/schemas/OpenAI.MessageContent' description: The text content that is part of a message. + OpenAI.ParallelToolCalls: + type: boolean + description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. OpenAI.PredictionContent: type: object required: diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index 730716937..c309c0632 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -5177,7 +5177,8 @@ components: tool_choice: $ref: '#/components/schemas/ChatCompletionToolChoiceOption' parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true user: type: string @@ -6648,7 +6649,8 @@ components: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' nullable: true parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true response_format: allOf: @@ -6836,7 +6838,8 @@ components: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' nullable: true parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true response_format: allOf: @@ -7397,7 +7400,8 @@ components: $ref: '#/components/schemas/ChatCompletionTool' description: A list of tools the model may generate JSON inputs for. parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true functions: type: array @@ -7499,7 +7503,8 @@ components: $ref: '#/components/schemas/ChatCompletionTool' description: A list of tools the model may generate JSON inputs for. parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true preferred_completion: type: array @@ -9190,6 +9195,9 @@ components: allOf: - $ref: '#/components/schemas/FileChunkingStrategyResponseParam' description: This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API. + ParallelToolCalls: + type: boolean + description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. PredictionContent: type: object required: @@ -12290,7 +12298,8 @@ components: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' nullable: true parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true response_format: allOf: diff --git a/.typespec/common/models.tsp b/.typespec/common/models.tsp index 9ad1b630e..3b0e9bf4f 100644 --- a/.typespec/common/models.tsp +++ b/.typespec/common/models.tsp @@ -87,7 +87,7 @@ model ResponseFormatJsonSchema extends OmniTypedResponseFormat { } /** Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. */ -alias ParallelToolCalls = boolean; +scalar ParallelToolCalls extends boolean; /** Usage statistics for the completion request. */ model CompletionUsage { diff --git a/README.md b/README.md index f913b25b8..107bd3586 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Date: Wed Jan 22 19:03:08 2025 +0000 Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk ``` -commit 7ec86ce9fbb544f7542979b601aaaec8c37263f6 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) +commit a81ceece96ec8634d1fd8b361b2e60f3b3f1fd62 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) Author: Travis Wilson -Date: Wed Jan 22 12:43:20 2025 -0800 +Date: Fri Jan 24 16:35:17 2025 -0800 ``` There are some deltas: From 1da30a854efa3ac3ee6715182522e6853a8eb821 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Mon, 27 Jan 2025 14:37:32 -0800 Subject: [PATCH 28/44] update for latest 2025-01-01-preview functionality (files is back) --- .../sdk/openai/Azure.AI.OpenAI/CHANGELOG.md | 4 + .../sdk/openai/Azure.AI.OpenAI/assets.json | 2 +- .../src/Custom/AzureOpenAIClientOptions.cs | 3 +- .../src/Custom/Files/OpenAIFileExtensions.cs | 21 +++++ .../tests/AzureOpenAIClientSmokeTests.cs | 41 ++++++++++ .../Azure.AI.OpenAI/tests/BatchTests.cs | 62 +++++--------- .../tests/ConversationTests.cs | 32 +++++--- .../openai/Azure.AI.OpenAI/tests/FileTests.cs | 4 +- .../Azure.AI.OpenAI/tests/FineTuningTests.cs | 81 ++++++++++++++----- 9 files changed, 172 insertions(+), 78 deletions(-) create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/OpenAIFileExtensions.cs create mode 100644 .dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/AzureOpenAIClientSmokeTests.cs diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md index 9a537d2e1..d77cb734b 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md @@ -8,6 +8,10 @@ New features include: - To be filled +### Breaking Changes + +- **Batch**: files uploaded for batch operations (`UploadFile` with `FileUploadPurpose.Batch`) will now report a `status` of `processed`, matching expected behavior against OpenAI's `/v1` endpoint. This is a change from past behavior where such files would initially report `pending` and a later `processed`, `error`, or other status depending on operation progress. Batch input validation is instead consistently performed from the batch client. + ## 2.1.0 (2024-12-05) This GA library release aligns functionality with the latest `2024-10-21` stable service API label. diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json index a1d970592..5f6312707 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "dotnet.azure/openai/Azure.AI.OpenAI", - "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_9a2aa7b69d" + "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_3d9f76dbf7" } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs index befca3770..9bfcb37cd 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureOpenAIClientOptions.cs @@ -122,7 +122,8 @@ internal string GetRawServiceApiValueForClient(object client) ServiceVersion defaultVersion = client switch { #if !AZURE_OPENAI_GA - AzureFileClient _ => ServiceVersion.V2024_10_01_Preview, + // Realtime (preview only) is currently *only* supported on 2024-10-01-preview; override default + // version selection for optimal out-of-the-box support if it's not explicitly specified. AzureRealtimeConversationClient _ => ServiceVersion.V2024_10_01_Preview, #endif #if !AZURE_OPENAI_GA diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/OpenAIFileExtensions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/OpenAIFileExtensions.cs new file mode 100644 index 000000000..620d1e004 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/OpenAIFileExtensions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.AI.OpenAI.Files; +using System.Diagnostics.CodeAnalysis; + +namespace Azure.AI.OpenAI; + +[Experimental("AOAI001")] +public static partial class OpenAIFileExtensions +{ + [Experimental("AOAI001")] + public static AzureOpenAIFileStatus GetAzureOpenAIFileStatus(this OpenAIFile file) + { + if (file is not AzureOpenAIFile azureFile) + { + throw new InvalidOperationException($"Azure OpenAI file status is only available on {nameof(OpenAIFile)} instances returned from a client configured for Azure OpenAI."); + } + return azureFile.Status.ToAzureOpenAIFileStatus(); + } +} \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/AzureOpenAIClientSmokeTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/AzureOpenAIClientSmokeTests.cs new file mode 100644 index 000000000..c4872a707 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/AzureOpenAIClientSmokeTests.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using Azure.AI.OpenAI.Tests.Utils.Config; +using OpenAI; +using System; + +namespace Azure.AI.OpenAI.Tests; + +[Category("Smoke")] +public class AzureOpenAIClientSmokeTests : AoaiTestBase +{ + private IConfiguration DefaultTestConfig { get; } + + public AzureOpenAIClientSmokeTests(bool isAsync) : base(isAsync) + { + DefaultTestConfig = TestConfig.GetConfig("default"); + } + + [Test] + public void CanCreateClient() + { + AzureOpenAIClient azureOpenAIClient = GetTestTopLevelClient(DefaultTestConfig); + Assert.That(azureOpenAIClient, Is.InstanceOf()); + Assert.That(azureOpenAIClient as OpenAIClient, Is.Not.Null); + } + + [Test] + public void VerifyAllVersionsStringify() + { + foreach (AzureOpenAIClientOptions.ServiceVersion possibleVersionValue + in Enum.GetValues(typeof(AzureOpenAIClientOptions.ServiceVersion))) + { + AzureOpenAIClientOptions clientOptionsWithVersion = new(possibleVersionValue); + string stringifiedVersion = clientOptionsWithVersion.GetRawServiceApiValueForClient(null); + Assert.That(stringifiedVersion, Is.Not.Null.And.Not.Empty); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs index 09c803217..c0d379b0e 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/BatchTests.cs @@ -1,27 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Azure.AI.OpenAI.Files; +using OpenAI.Batch; +using OpenAI.Chat; +using OpenAI.Files; +using OpenAI.TestFramework; using System; using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Net.Http; using System.Text.Json; -using System.Text.RegularExpressions; using System.Threading.Tasks; -using Azure.AI.OpenAI.Files; -using Azure.AI.OpenAI.Tests.Models; -using Azure.AI.OpenAI.Tests.Utils; -using Azure.AI.OpenAI.Tests.Utils.Config; -using OpenAI.Batch; -using OpenAI.Chat; -using OpenAI.Embeddings; -using OpenAI.Files; -using OpenAI.TestFramework; -using OpenAI.TestFramework.Mocks; -using OpenAI.TestFramework.Utils; namespace Azure.AI.OpenAI.Tests; @@ -40,12 +32,12 @@ public BatchTests(bool isAsync) : base(isAsync) [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif - //[TestCase(null)] + [TestCase(null)] public async Task CanUploadFileForBatch(AzureOpenAIClientOptions.ServiceVersion? version) { BatchClient batchClient = GetTestClient(GetTestClientOptions(version)); @@ -57,27 +49,23 @@ public async Task CanUploadFileForBatch(AzureOpenAIClientOptions.ServiceVersion? FileUploadPurpose.Batch); Validate(newFile); - AzureOpenAIFileStatus azureStatus = newFile.Status.ToAzureOpenAIFileStatus(); - Assert.That(azureStatus, Is.EqualTo(AzureOpenAIFileStatus.Pending)); + // In contrast to fine-tuning, files uploaded for batch will immediately enter -- and remain -- in a + // 'processed' state. Validation is performed via the batch client directly. + AzureOpenAIFileStatus azureStatus = newFile.GetAzureOpenAIFileStatus(); + Assert.That(azureStatus, Is.EqualTo(AzureOpenAIFileStatus.Processed)); - TimeSpan filePollingInterval = Recording!.Mode == RecordedTestMode.Playback ? TimeSpan.FromMilliseconds(1) : TimeSpan.FromSeconds(5); - - for (int i = 0; i < 10 && azureStatus == AzureOpenAIFileStatus.Pending; i++) - { - await Task.Delay(filePollingInterval); - newFile = await fileClient.GetFileAsync(newFile.Id); - azureStatus = newFile.Status.ToAzureOpenAIFileStatus(); - } - - Assert.That(azureStatus, Is.EqualTo(AzureOpenAIFileStatus.Error)); - Assert.That(newFile.StatusDetails, Does.Contain("valid json")); + string createdFileId = newFile.Id; + newFile = await fileClient.GetFileAsync(createdFileId); + Validate(newFile); + Assert.That(newFile.Id, Is.EqualTo(createdFileId)); + Assert.That(newFile.GetAzureOpenAIFileStatus(), Is.EqualTo(AzureOpenAIFileStatus.Processed)); } [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - // [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - // [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif @@ -132,12 +120,12 @@ public async Task CanCancelBatch(AzureOpenAIClientOptions.ServiceVersion? versio [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif - //[TestCase(null)] + [TestCase(null)] [Category("LongRunning")] // observed live runtime typically varies from 6 - 15 minutes public async Task SimpleBatchCompletionsTest(AzureOpenAIClientOptions.ServiceVersion? version) { @@ -235,12 +223,6 @@ public async Task SimpleBatchCompletionsTest(AzureOpenAIClientOptions.ServiceVer private TestClientOptions GetTestClientOptions(AzureOpenAIClientOptions.ServiceVersion? version) { -#if !AZURE_OPENAI_GA - if (version != AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview) - { - Assert.Inconclusive("/batches not yet fully supported after 2024-10-01-preview"); - } -#endif return version is null ? new TestClientOptions() : new TestClientOptions(version.Value); } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs index c5a83a276..2ea29e967 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ConversationTests.cs @@ -1,6 +1,4 @@ -using NUnit.Framework; -using OpenAI; -using OpenAI.RealtimeConversation; +using OpenAI.RealtimeConversation; using System; using System.ClientModel.Primitives; using System.Collections.Generic; @@ -20,7 +18,24 @@ public class ConversationTests : ConversationTestFixtureBase { public ConversationTests(bool isAsync) : base(isAsync) { } -#if !AZURE_OPENAI_GA +#if AZURE_OPENAI_GA + [Test] + [Category("Smoke")] + public void VersionNotSupportedThrows() + { + Assert.Throws(() => GetTestClient()); + } +#elif !NET + [Test] + public void ThrowsOnOldNetFramework() + { + _ = Assert.ThrowsAsync(async () => + { + RealtimeConversationClient client = GetTestClient(); + using RealtimeConversationSession session = await client.StartConversationSessionAsync(CancellationToken); + }); + } +#else [Test] [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] @@ -519,12 +534,5 @@ await session.SendCommandAsync( Assert.That(gotErrorUpdate, Is.True); } -#else - [Test] - [Category("Smoke")] - public void VersionNotSupportedThrows() - { - Assert.Throws(() => GetTestClient()); - } -#endif +#endif // "else" to AZURE_OPENAI_GA, !NET } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs index 03f46e867..aefe3c227 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs @@ -43,8 +43,8 @@ public async Task CanUploadAndDeleteFiles(AzureOpenAIClientOptions.ServiceVersio [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs index 7830ebab8..2a99737f5 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/FineTuningTests.cs @@ -17,6 +17,8 @@ using OpenAI.FineTuning; using OpenAI.TestFramework; using OpenAI.TestFramework.Utils; +using Azure.AI.OpenAI.Files; + #if !AZURE_OPENAI_GA using Azure.AI.OpenAI.FineTuning; @@ -24,6 +26,8 @@ namespace Azure.AI.OpenAI.Tests; +#pragma warning disable CS0618 + [Category("FineTuning")] public class FineTuningTests : AoaiTestBase { @@ -39,8 +43,47 @@ public FineTuningTests(bool isAsync) : base(isAsync) [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] +#else + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] +#endif + [TestCase(null)] + public async Task CanUploadFileForFineTuning(AzureOpenAIClientOptions.ServiceVersion? version) + { + FineTuningClient ftClient = GetTestClient(GetTestClientOptions(version)); + OpenAIFileClient fileClient = GetTestClientFrom(ftClient); + + OpenAIFile newFile = await fileClient.UploadFileAsync( + BinaryData.FromString("this isn't valid input for fine tuning"), + "intentionally-bad-ft-input.jsonl", + FileUploadPurpose.FineTune); + Validate(newFile); + + // In contrast to batch, files uploaded for fine tuning will initially appear in a 'pending' state, + // transitioning into a terminal as input validation is handled. In this case, because malformed input is + // uploaded, the terminal status should be 'error'. + AzureOpenAIFileStatus azureStatus = newFile.GetAzureOpenAIFileStatus(); + Assert.That(azureStatus, Is.EqualTo(AzureOpenAIFileStatus.Pending)); + + TimeSpan filePollingInterval = Recording!.Mode == RecordedTestMode.Playback ? TimeSpan.FromMilliseconds(1) : TimeSpan.FromSeconds(5); + + for (int i = 0; i < 10 && azureStatus == AzureOpenAIFileStatus.Pending; i++) + { + await Task.Delay(filePollingInterval); + newFile = await fileClient.GetFileAsync(newFile.Id); + azureStatus = newFile.GetAzureOpenAIFileStatus(); + } + + Assert.That(azureStatus, Is.EqualTo(AzureOpenAIFileStatus.Error)); + Assert.That(newFile.StatusDetails.ToLower(), Does.Contain("validation of jsonl")); + } + + [RecordedTest] +#if !AZURE_OPENAI_GA + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif @@ -69,12 +112,12 @@ public async Task JobsFineTuning(AzureOpenAIClientOptions.ServiceVersion? versio [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif - //[TestCase(null)] + [TestCase(null)] public async Task CheckpointsFineTuning(AzureOpenAIClientOptions.ServiceVersion? version) { FineTuningClient client = GetTestClient(GetTestClientOptions(version)); @@ -114,8 +157,8 @@ public async Task CheckpointsFineTuning(AzureOpenAIClientOptions.ServiceVersion? [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif @@ -160,12 +203,12 @@ public async Task EventsFineTuning(AzureOpenAIClientOptions.ServiceVersion? vers [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif - //[TestCase(null)] + [TestCase(null)] public async Task CreateAndCancelFineTuning(AzureOpenAIClientOptions.ServiceVersion? version) { FineTuningClient client = GetTestClient(GetTestClientOptions(version)); @@ -230,12 +273,12 @@ public async Task CreateAndCancelFineTuning(AzureOpenAIClientOptions.ServiceVers [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif - //[TestCase(null)] + [TestCase(null)] public async Task CreateAndDeleteFineTuning(AzureOpenAIClientOptions.ServiceVersion? version) { FineTuningClient client = GetTestClient(GetTestClientOptions(version)); @@ -275,12 +318,12 @@ public async Task CreateAndDeleteFineTuning(AzureOpenAIClientOptions.ServiceVers [RecordedTest] #if !AZURE_OPENAI_GA [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] - //[TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_Preview)] + [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2025_01_01_Preview)] #else [TestCase(AzureOpenAIClientOptions.ServiceVersion.V2024_10_21)] #endif - //[TestCase(null)] + [TestCase(null)] [Category("LongRunning")] // CAUTION: This test can take around 10 to 15 *minutes* in live mode to run public async Task DeployAndChatWithModel(AzureOpenAIClientOptions.ServiceVersion? version) { @@ -361,12 +404,6 @@ public async Task DeployAndChatWithModel(AzureOpenAIClientOptions.ServiceVersion private TestClientOptions GetTestClientOptions(AzureOpenAIClientOptions.ServiceVersion? version) { -#if !AZURE_OPENAI_GA - if (version != AzureOpenAIClientOptions.ServiceVersion.V2024_10_01_Preview) - { - Assert.Inconclusive("fine tuning is not yet fully supported after 2024-10-01-preview"); - } -#endif return version is null ? new TestClientOptions() : new TestClientOptions(version.Value); } From d5f3a14ecf3b7993428f46cfbe4fd87b3ce51dd0 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Mon, 27 Jan 2025 15:03:27 -0800 Subject: [PATCH 29/44] fix developer message ordering to preserve int stability --- .dotnet/api/OpenAI.netstandard2.0.cs | 10 +++++----- .dotnet/src/Custom/Chat/ChatMessageRole.cs | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 6990fde32..8260f96da 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1353,11 +1353,11 @@ public enum ChatMessageContentPartKind { } public enum ChatMessageRole { System = 0, - Developer = 1, - User = 2, - Assistant = 3, - Tool = 4, - Function = 5 + User = 1, + Assistant = 2, + Tool = 3, + Function = 4, + Developer = 5 } public class ChatOutputAudio : IJsonModel, IPersistableModel { public BinaryData AudioBytes { get; } diff --git a/.dotnet/src/Custom/Chat/ChatMessageRole.cs b/.dotnet/src/Custom/Chat/ChatMessageRole.cs index 83bbba718..53dce4c77 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageRole.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageRole.cs @@ -64,16 +64,6 @@ public enum ChatMessageRole [CodeGenMember("System")] System, - /// - /// The developer role, which provides instructions to the model that guide the behavior of future - /// assistant messages - /// - /// - /// developer replaces system when using o1 and newer models. - /// - [CodeGenMember("Developer")] - Developer, - /// /// The user role that provides input from the caller as a prompt for model responses. /// @@ -107,4 +97,14 @@ public enum ChatMessageRole /// [CodeGenMember("Function")] Function, + + /// + /// The developer role, which provides instructions to the model that guide the behavior of future + /// assistant messages + /// + /// + /// developer replaces system when using o1 and newer models. + /// + [CodeGenMember("Developer")] + Developer, } \ No newline at end of file From a6394c431125b3e6d27f5d5ab005af6480935ca4 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Mon, 27 Jan 2025 17:41:32 -0800 Subject: [PATCH 30/44] minor update, including gitattributes QoL merge from Chris's old PR --- .gitattributes | 3 ++- README.md | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index dada1ce9c..ab873d008 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ *.cs text=auto -*.tsp text=auto \ No newline at end of file +*.tsp text=auto +*.yaml text=auto \ No newline at end of file diff --git a/README.md b/README.md index 107bd3586..dddc918d7 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Date: Wed Jan 22 19:03:08 2025 +0000 Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk ``` -commit a81ceece96ec8634d1fd8b361b2e60f3b3f1fd62 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) +commit f9e16b8f3216c20b03fb3dd0083e3b03a11bce34 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) Author: Travis Wilson -Date: Fri Jan 24 16:35:17 2025 -0800 +Date: Mon Jan 27 17:36:50 2025 -0800 ``` There are some deltas: From b3a4737b9dcd95462e3f049039cf56dcca393c99 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Tue, 28 Jan 2025 15:56:51 -0800 Subject: [PATCH 31/44] prediction now works, so enable it! --- .dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json | 2 +- .../sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json index 5f6312707..5d8915c07 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "dotnet.azure/openai/Azure.AI.OpenAI", - "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_3d9f76dbf7" + "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_be978e5b29" } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs index 972d699ce..3d84ee7a3 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs @@ -746,13 +746,9 @@ public async Task ChatWithO1Works() #if NET [RecordedTest] - [Ignore("Pending model deployment availability with prediction support")] public async Task PredictedOutputsWork() { - IConfiguration tipConfig = TestConfig.GetConfig("tip")!; - - AzureOpenAIClient azureOpenAIClient = GetTestTopLevelClient(tipConfig); - ChatClient client = azureOpenAIClient.GetChatClient("gpt-4o"); + ChatClient client = GetTestClient(); ChatCompletionOptions options = new() { @@ -768,7 +764,7 @@ public async Task PredictedOutputsWork() }; ChatMessage message = ChatMessage.CreateUserMessage(""" - Modify the following input to enable the feature. Only respond with the JSON and include no other text. + Modify the following input to enable the feature. Only respond with the JSON and include no other text. Do not enclose in markdown backticks or any other syntax; just provide the JSON object. { "feature_name": "test_feature", From 62bd0122970070e55023c901de864de640e47033 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 30 Jan 2025 18:49:44 -0800 Subject: [PATCH 32/44] incorporate tool update for anonymous array element extraction --- .../Custom/Common/Internal/GeneratorStubs.cs | 2 +- .../Common/RequestContentFilterResult.cs | 2 +- .../Common/ResponseContentFilterResult.cs | 2 +- ...lterResultForChoiceError.Serialization.cs} | 40 +-- ...AzureContentFilterResultForChoiceError.cs} | 16 +- ...romptContentFilterResults.Serialization.cs | 4 +- ...lterResultForPromptContentFilterResults.cs | 4 +- ...sponseContentFilterResult.Serialization.cs | 6 +- .../Generated/ResponseContentFilterResult.cs | 2 +- .../Custom/Chat/Internal/GeneratorStubs.cs | 2 +- ...pi3-azure-openai-2024-06-01-generated.yaml | 282 ++++++++++------ ...e-openai-2024-08-01-preview-generated.yaml | 282 ++++++++++------ ...e-openai-2024-09-01-preview-generated.yaml | 282 ++++++++++------ ...e-openai-2024-10-01-preview-generated.yaml | 317 ++++++++++++------ ...pi3-azure-openai-2024-10-21-generated.yaml | 282 ++++++++++------ ...e-openai-2024-12-01-preview-generated.yaml | 317 ++++++++++++------ ...e-openai-2025-01-01-preview-generated.yaml | 317 ++++++++++++------ .openapi3/openapi3-openai.yaml | 143 +++----- .typespec.azure/chat/models.response.tsp | 16 +- .typespec/administration/models.tsp | 34 +- .typespec/batch/models.tsp | 29 +- .typespec/chat/models.tsp | 193 ++++++----- .typespec/completions/models.tsp | 37 +- .typespec/fine-tuning/models.tsp | 15 +- .typespec/messages/models.tsp | 38 +-- .typespec/runs/models.tsp | 53 ++- README.md | 4 +- 27 files changed, 1681 insertions(+), 1040 deletions(-) rename .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/{InternalAzureContentFilterResultForPromptContentFilterResultsError.Serialization.cs => InternalAzureContentFilterResultForChoiceError.Serialization.cs} (65%) rename .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/{InternalAzureContentFilterResultForPromptContentFilterResultsError.cs => InternalAzureContentFilterResultForChoiceError.cs} (78%) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/Internal/GeneratorStubs.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/Internal/GeneratorStubs.cs index befcbe59a..a687e0bf6 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/Internal/GeneratorStubs.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/Internal/GeneratorStubs.cs @@ -9,7 +9,7 @@ namespace Azure.AI.OpenAI; [Experimental("AOAI001")][CodeGenModel("AzureContentFilterBlocklistIdResult")] internal partial class InternalAzureContentFilterBlocklistIdResult { } [Experimental("AOAI001")][CodeGenModel("AzureContentFilterBlocklistResultDetail")] internal partial class InternalAzureContentFilterBlocklistResultDetail { } [Experimental("AOAI001")][CodeGenModel("AzureContentFilterResultForPromptContentFilterResults")] internal partial class InternalAzureContentFilterResultForPromptContentFilterResults { } -[Experimental("AOAI001")][CodeGenModel("AzureContentFilterResultForPromptContentFilterResultsError")] internal partial class InternalAzureContentFilterResultForPromptContentFilterResultsError { } +[Experimental("AOAI001")][CodeGenModel("AzureContentFilterResultForChoiceError")] internal partial class InternalAzureContentFilterResultForChoiceError { } #if AZURE_OPENAI_GA [Experimental("AOAI001")][CodeGenModel("AzureContentFilterCompletionTextSpan")] internal partial class ContentFilterTextSpan { } #endif \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/RequestContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/RequestContentFilterResult.cs index 11a086ab7..e61e42729 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/RequestContentFilterResult.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/RequestContentFilterResult.cs @@ -15,7 +15,7 @@ public partial class RequestContentFilterResult internal InternalAzureContentFilterResultForPromptContentFilterResults InternalResults { get; } /// - internal InternalAzureContentFilterResultForPromptContentFilterResultsError Error { get; set; } + internal InternalAzureContentFilterResultForChoiceError Error { get; set; } /// public ContentFilterSeverityResult Sexual => InternalResults?.Sexual; diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/ResponseContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/ResponseContentFilterResult.cs index c73b08da3..f363d05db 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/ResponseContentFilterResult.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/ResponseContentFilterResult.cs @@ -9,7 +9,7 @@ namespace Azure.AI.OpenAI; [CodeGenModel("AzureContentFilterResultForChoice")] public partial class ResponseContentFilterResult { - internal InternalAzureContentFilterResultForPromptContentFilterResultsError Error { get; } + internal InternalAzureContentFilterResultForChoiceError Error { get; } #if !AZURE_OPENAI_GA public ContentFilterTextSpanResult UngroundedMaterial { get; } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResultsError.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.Serialization.cs similarity index 65% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResultsError.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.Serialization.cs index d3553f76f..3577b2606 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResultsError.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.Serialization.cs @@ -10,9 +10,9 @@ namespace Azure.AI.OpenAI { - internal partial class InternalAzureContentFilterResultForPromptContentFilterResultsError : IJsonModel + internal partial class InternalAzureContentFilterResultForChoiceError : IJsonModel { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -23,10 +23,10 @@ void IJsonModel The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForPromptContentFilterResultsError)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForChoiceError)} does not support writing '{format}' format."); } if (SerializedAdditionalRawData?.ContainsKey("code") != true) @@ -60,19 +60,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalAzureContentFilterResultForPromptContentFilterResultsError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureContentFilterResultForChoiceError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForPromptContentFilterResultsError)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForChoiceError)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAzureContentFilterResultForPromptContentFilterResultsError(document.RootElement, options); + return DeserializeInternalAzureContentFilterResultForChoiceError(document.RootElement, options); } - internal static InternalAzureContentFilterResultForPromptContentFilterResultsError DeserializeInternalAzureContentFilterResultForPromptContentFilterResultsError(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureContentFilterResultForChoiceError DeserializeInternalAzureContentFilterResultForChoiceError(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -103,46 +103,46 @@ internal static InternalAzureContentFilterResultForPromptContentFilterResultsErr } } serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureContentFilterResultForPromptContentFilterResultsError(code, message, serializedAdditionalRawData); + return new InternalAzureContentFilterResultForChoiceError(code, message, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForPromptContentFilterResultsError)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForChoiceError)} does not support writing '{options.Format}' format."); } } - InternalAzureContentFilterResultForPromptContentFilterResultsError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + InternalAzureContentFilterResultForChoiceError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAzureContentFilterResultForPromptContentFilterResultsError(document.RootElement, options); + return DeserializeInternalAzureContentFilterResultForChoiceError(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForPromptContentFilterResultsError)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForChoiceError)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The result to deserialize the model from. - internal static InternalAzureContentFilterResultForPromptContentFilterResultsError FromResponse(PipelineResponse response) + internal static InternalAzureContentFilterResultForChoiceError FromResponse(PipelineResponse response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureContentFilterResultForPromptContentFilterResultsError(document.RootElement); + return DeserializeInternalAzureContentFilterResultForChoiceError(document.RootElement); } /// Convert into a . diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResultsError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.cs similarity index 78% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResultsError.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.cs index 212b8c284..a31195cb6 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResultsError.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.cs @@ -7,8 +7,8 @@ namespace Azure.AI.OpenAI { - /// The AzureContentFilterResultForPromptContentFilterResultsError. - internal partial class InternalAzureContentFilterResultForPromptContentFilterResultsError + /// The AzureContentFilterResultForChoiceError. + internal partial class InternalAzureContentFilterResultForChoiceError { /// /// Keeps track of any properties unknown to the library. @@ -41,11 +41,11 @@ internal partial class InternalAzureContentFilterResultForPromptContentFilterRes /// /// internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . + /// Initializes a new instance of . /// A distinct, machine-readable code associated with the error. /// A human-readable message associated with the error. /// is null. - internal InternalAzureContentFilterResultForPromptContentFilterResultsError(int code, string message) + internal InternalAzureContentFilterResultForChoiceError(int code, string message) { Argument.AssertNotNull(message, nameof(message)); @@ -53,19 +53,19 @@ internal InternalAzureContentFilterResultForPromptContentFilterResultsError(int Message = message; } - /// Initializes a new instance of . + /// Initializes a new instance of . /// A distinct, machine-readable code associated with the error. /// A human-readable message associated with the error. /// Keeps track of any properties unknown to the library. - internal InternalAzureContentFilterResultForPromptContentFilterResultsError(int code, string message, IDictionary serializedAdditionalRawData) + internal InternalAzureContentFilterResultForChoiceError(int code, string message, IDictionary serializedAdditionalRawData) { Code = code; Message = message; SerializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal InternalAzureContentFilterResultForPromptContentFilterResultsError() + /// Initializes a new instance of for deserialization. + internal InternalAzureContentFilterResultForChoiceError() { } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs index 7b888475f..c1e393eac 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs @@ -121,7 +121,7 @@ internal static InternalAzureContentFilterResultForPromptContentFilterResults De ContentFilterSeverityResult selfHarm = default; ContentFilterDetectionResult profanity = default; ContentFilterBlocklistResult customBlocklists = default; - InternalAzureContentFilterResultForPromptContentFilterResultsError error = default; + InternalAzureContentFilterResultForChoiceError error = default; ContentFilterDetectionResult jailbreak = default; ContentFilterDetectionResult indirectAttack = default; IDictionary serializedAdditionalRawData = default; @@ -188,7 +188,7 @@ internal static InternalAzureContentFilterResultForPromptContentFilterResults De { continue; } - error = InternalAzureContentFilterResultForPromptContentFilterResultsError.DeserializeInternalAzureContentFilterResultForPromptContentFilterResultsError(property.Value, options); + error = InternalAzureContentFilterResultForChoiceError.DeserializeInternalAzureContentFilterResultForChoiceError(property.Value, options); continue; } if (property.NameEquals("jailbreak"u8)) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.cs index b45626184..4887bb919 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.cs @@ -100,7 +100,7 @@ internal InternalAzureContentFilterResultForPromptContentFilterResults(ContentFi /// the user. /// /// Keeps track of any properties unknown to the library. - internal InternalAzureContentFilterResultForPromptContentFilterResults(ContentFilterSeverityResult sexual, ContentFilterSeverityResult hate, ContentFilterSeverityResult violence, ContentFilterSeverityResult selfHarm, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, InternalAzureContentFilterResultForPromptContentFilterResultsError error, ContentFilterDetectionResult jailbreak, ContentFilterDetectionResult indirectAttack, IDictionary serializedAdditionalRawData) + internal InternalAzureContentFilterResultForPromptContentFilterResults(ContentFilterSeverityResult sexual, ContentFilterSeverityResult hate, ContentFilterSeverityResult violence, ContentFilterSeverityResult selfHarm, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, InternalAzureContentFilterResultForChoiceError error, ContentFilterDetectionResult jailbreak, ContentFilterDetectionResult indirectAttack, IDictionary serializedAdditionalRawData) { Sexual = sexual; Hate = hate; @@ -151,7 +151,7 @@ internal InternalAzureContentFilterResultForPromptContentFilterResults() /// A collection of binary filtering outcomes for configured custom blocklists. internal ContentFilterBlocklistResult CustomBlocklists { get; set; } /// If present, details about an error that prevented content filtering from completing its evaluation. - internal InternalAzureContentFilterResultForPromptContentFilterResultsError Error { get; set; } + internal InternalAzureContentFilterResultForChoiceError Error { get; set; } /// /// A detection result that describes user prompt injection attacks, where malicious users deliberately exploit /// system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.Serialization.cs index 1b9604e0c..a45212164 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.Serialization.cs @@ -62,7 +62,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (SerializedAdditionalRawData?.ContainsKey("error") != true && Optional.IsDefined(Error)) { writer.WritePropertyName("error"u8); - writer.WriteObjectValue(Error, options); + writer.WriteObjectValue(Error, options); } if (SerializedAdditionalRawData?.ContainsKey("protected_material_text") != true && Optional.IsDefined(ProtectedMaterialText)) { @@ -126,7 +126,7 @@ internal static ResponseContentFilterResult DeserializeResponseContentFilterResu ContentFilterSeverityResult selfHarm = default; ContentFilterDetectionResult profanity = default; ContentFilterBlocklistResult customBlocklists = default; - InternalAzureContentFilterResultForPromptContentFilterResultsError error = default; + InternalAzureContentFilterResultForChoiceError error = default; ContentFilterDetectionResult protectedMaterialText = default; ContentFilterProtectedMaterialResult protectedMaterialCode = default; ContentFilterTextSpanResult ungroundedMaterial = default; @@ -194,7 +194,7 @@ internal static ResponseContentFilterResult DeserializeResponseContentFilterResu { continue; } - error = InternalAzureContentFilterResultForPromptContentFilterResultsError.DeserializeInternalAzureContentFilterResultForPromptContentFilterResultsError(property.Value, options); + error = InternalAzureContentFilterResultForChoiceError.DeserializeInternalAzureContentFilterResultForChoiceError(property.Value, options); continue; } if (property.NameEquals("protected_material_text"u8)) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.cs index 6a8ac7cf0..45fdc12f1 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.cs @@ -77,7 +77,7 @@ internal ResponseContentFilterResult() /// A detection result that describes a match against licensed code or other protected source material. /// /// Keeps track of any properties unknown to the library. - internal ResponseContentFilterResult(ContentFilterSeverityResult sexual, ContentFilterSeverityResult hate, ContentFilterSeverityResult violence, ContentFilterSeverityResult selfHarm, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, InternalAzureContentFilterResultForPromptContentFilterResultsError error, ContentFilterDetectionResult protectedMaterialText, ContentFilterProtectedMaterialResult protectedMaterialCode, ContentFilterTextSpanResult ungroundedMaterial, IDictionary serializedAdditionalRawData) + internal ResponseContentFilterResult(ContentFilterSeverityResult sexual, ContentFilterSeverityResult hate, ContentFilterSeverityResult violence, ContentFilterSeverityResult selfHarm, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, InternalAzureContentFilterResultForChoiceError error, ContentFilterDetectionResult protectedMaterialText, ContentFilterProtectedMaterialResult protectedMaterialCode, ContentFilterTextSpanResult ungroundedMaterial, IDictionary serializedAdditionalRawData) { Sexual = sexual; Hate = hate; diff --git a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs index 41cf4c062..f72b9918a 100644 --- a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs @@ -36,7 +36,7 @@ internal readonly partial struct InternalChatCompletionResponseMessageRole { } [CodeGenModel("ChatCompletionStreamOptions")] internal partial class InternalChatCompletionStreamOptions { } -[CodeGenModel("ChatCompletionStreamResponseDeltaRole")] +[CodeGenModel("ChatCompletionStreamResponseDeltaRole2")] internal readonly partial struct InternalChatCompletionStreamResponseDeltaRole { } [CodeGenModel("CreateChatCompletionFunctionResponse")] diff --git a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml index 5ccf8fe35..a55898dfa 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-06-01-generated.yaml @@ -483,6 +483,90 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -912,66 +996,14 @@ components: type: object required: - id - - choices - created - model - object + - choices properties: id: type: string description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. created: type: integer format: unixtime @@ -999,6 +1031,10 @@ components: description: The object type, which is always `chat.completion`. usage: $ref: '#/components/schemas/OpenAI.CompletionUsage' + choices: + type: array + items: + $ref: '#/components/schemas/AzureCreateChatCompletionResponseChoice' prompt_filter_results: type: array items: @@ -1019,6 +1055,60 @@ components: description: |- The extended top-level chat completion response model for the Azure OpenAI service. This model adds Responsible AI content filter annotations for prompt input. + AzureCreateChatCompletionResponseChoice: + type: object + required: + - finish_reason + - index + - message + - logprobs + - content_filter_results + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForChoice' + description: The Responsible AI content filter annotations associated with the choice. AzureImage: type: object required: @@ -1247,46 +1337,6 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 - CreateMessageRequestAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools - MessageObjectAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true OpenAI.AssistantToolDefinition: type: object required: @@ -1803,9 +1853,10 @@ components: format: float description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' + type: array + items: + type: integer + format: int32 nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -1986,9 +2037,24 @@ components: $ref: '#/components/schemas/OpenAI.MessageContent' x-oaiExpandable: true attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: @@ -2378,9 +2444,21 @@ components: nullable: true description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true nullable: true description: A list of files attached to the message, and the tools they were added to. metadata: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml index 30aaca70a..889aa29b1 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-08-01-preview-generated.yaml @@ -586,6 +586,90 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -1004,66 +1088,14 @@ components: type: object required: - id - - choices - created - model - object + - choices properties: id: type: string description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. created: type: integer format: unixtime @@ -1091,6 +1123,10 @@ components: description: The object type, which is always `chat.completion`. usage: $ref: '#/components/schemas/OpenAI.CompletionUsage' + choices: + type: array + items: + $ref: '#/components/schemas/AzureCreateChatCompletionResponseChoice' prompt_filter_results: type: array items: @@ -1111,6 +1147,60 @@ components: description: |- The extended top-level chat completion response model for the Azure OpenAI service. This model adds Responsible AI content filter annotations for prompt input. + AzureCreateChatCompletionResponseChoice: + type: object + required: + - finish_reason + - index + - message + - logprobs + - content_filter_results + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForChoice' + description: The Responsible AI content filter annotations associated with the choice. AzureImage: type: object required: @@ -1333,30 +1423,6 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 - CreateMessageRequestAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools ElasticsearchChatDataSource: type: object required: @@ -1455,22 +1521,6 @@ components: description: The parameter information to control the use of the Elasticsearch data source. allOf: - $ref: '#/components/schemas/AzureChatDataSource' - MessageObjectAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true MongoDBChatDataSource: type: object required: @@ -2141,9 +2191,10 @@ components: format: float description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' + type: array + items: + type: integer + format: int32 nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2373,9 +2424,24 @@ components: $ref: '#/components/schemas/OpenAI.MessageContent' x-oaiExpandable: true attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: @@ -2765,9 +2831,21 @@ components: nullable: true description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true nullable: true description: A list of files attached to the message, and the tools they were added to. metadata: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml index 208b654cb..7e7576d6d 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-09-01-preview-generated.yaml @@ -586,6 +586,90 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -1019,66 +1103,14 @@ components: type: object required: - id - - choices - created - model - object + - choices properties: id: type: string description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. created: type: integer format: unixtime @@ -1106,6 +1138,10 @@ components: description: The object type, which is always `chat.completion`. usage: $ref: '#/components/schemas/OpenAI.CompletionUsage' + choices: + type: array + items: + $ref: '#/components/schemas/AzureCreateChatCompletionResponseChoice' prompt_filter_results: type: array items: @@ -1126,6 +1162,60 @@ components: description: |- The extended top-level chat completion response model for the Azure OpenAI service. This model adds Responsible AI content filter annotations for prompt input. + AzureCreateChatCompletionResponseChoice: + type: object + required: + - finish_reason + - index + - message + - logprobs + - content_filter_results + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForChoice' + description: The Responsible AI content filter annotations associated with the choice. AzureImage: type: object required: @@ -1348,30 +1438,6 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 - CreateMessageRequestAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools ElasticsearchChatDataSource: type: object required: @@ -1470,22 +1536,6 @@ components: description: The parameter information to control the use of the Elasticsearch data source. allOf: - $ref: '#/components/schemas/AzureChatDataSource' - MessageObjectAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true MongoDBChatDataSource: type: object required: @@ -2163,9 +2213,10 @@ components: format: float description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' + type: array + items: + type: integer + format: int32 nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2422,9 +2473,24 @@ components: $ref: '#/components/schemas/OpenAI.MessageContent' x-oaiExpandable: true attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: @@ -2814,9 +2880,21 @@ components: nullable: true description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true nullable: true description: A list of files attached to the message, and the tools they were added to. metadata: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml index 268a57d76..ff733c48b 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-01-preview-generated.yaml @@ -514,6 +514,39 @@ components: - id description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. description: A collection of true/false filtering results for configured custom blocklists. + AzureContentFilterCompletionTextSpan: + type: object + required: + - completion_start_offset + - completion_end_offset + properties: + completion_start_offset: + type: integer + format: int32 + description: Offset of the UTF32 code point which begins the span. + completion_end_offset: + type: integer + format: int32 + description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. + description: A representation of a span of completion text as used by Azure OpenAI content filter results. + AzureContentFilterCompletionTextSpanDetectionResult: + type: object + required: + - filtered + - detected + - details + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + details: + type: array + items: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' + description: Detailed information about the detected completion text spans. AzureContentFilterDetectionResult: type: object required: @@ -586,6 +619,92 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + ungrounded_material: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' + description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -1019,66 +1138,14 @@ components: type: object required: - id - - choices - created - model - object + - choices properties: id: type: string description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. created: type: integer format: unixtime @@ -1106,6 +1173,10 @@ components: description: The object type, which is always `chat.completion`. usage: $ref: '#/components/schemas/OpenAI.CompletionUsage' + choices: + type: array + items: + $ref: '#/components/schemas/AzureCreateChatCompletionResponseChoice' prompt_filter_results: type: array items: @@ -1126,6 +1197,60 @@ components: description: |- The extended top-level chat completion response model for the Azure OpenAI service. This model adds Responsible AI content filter annotations for prompt input. + AzureCreateChatCompletionResponseChoice: + type: object + required: + - finish_reason + - index + - message + - logprobs + - content_filter_results + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForChoice' + description: The Responsible AI content filter annotations associated with the choice. AzureImage: type: object required: @@ -1348,30 +1473,6 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 - CreateMessageRequestAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools ElasticsearchChatDataSource: type: object required: @@ -1470,22 +1571,6 @@ components: description: The parameter information to control the use of the Elasticsearch data source. allOf: - $ref: '#/components/schemas/AzureChatDataSource' - MessageObjectAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true MongoDBChatDataSource: type: object required: @@ -2163,9 +2248,10 @@ components: format: float description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' + type: array + items: + type: integer + format: int32 nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2434,9 +2520,24 @@ components: $ref: '#/components/schemas/OpenAI.MessageContent' x-oaiExpandable: true attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: @@ -2826,9 +2927,21 @@ components: nullable: true description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true nullable: true description: A list of files attached to the message, and the tools they were added to. metadata: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml index d2366ca7d..fdc5a0cf5 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-10-21-generated.yaml @@ -483,6 +483,90 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -916,66 +1000,14 @@ components: type: object required: - id - - choices - created - model - object + - choices properties: id: type: string description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. created: type: integer format: unixtime @@ -1003,6 +1035,10 @@ components: description: The object type, which is always `chat.completion`. usage: $ref: '#/components/schemas/OpenAI.CompletionUsage' + choices: + type: array + items: + $ref: '#/components/schemas/AzureCreateChatCompletionResponseChoice' prompt_filter_results: type: array items: @@ -1023,6 +1059,60 @@ components: description: |- The extended top-level chat completion response model for the Azure OpenAI service. This model adds Responsible AI content filter annotations for prompt input. + AzureCreateChatCompletionResponseChoice: + type: object + required: + - finish_reason + - index + - message + - logprobs + - content_filter_results + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForChoice' + description: The Responsible AI content filter annotations associated with the choice. AzureImage: type: object required: @@ -1245,46 +1335,6 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 - CreateMessageRequestAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools - MessageObjectAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true OpenAI.AssistantToolDefinition: type: object required: @@ -1841,9 +1891,10 @@ components: format: float description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' + type: array + items: + type: integer + format: int32 nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2112,9 +2163,24 @@ components: $ref: '#/components/schemas/OpenAI.MessageContent' x-oaiExpandable: true attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: @@ -2504,9 +2570,21 @@ components: nullable: true description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true nullable: true description: A list of files attached to the message, and the tools they were added to. metadata: diff --git a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml index 73ea16ab7..c4c4225a2 100644 --- a/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2024-12-01-preview-generated.yaml @@ -515,6 +515,39 @@ components: - id description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. description: A collection of true/false filtering results for configured custom blocklists. + AzureContentFilterCompletionTextSpan: + type: object + required: + - completion_start_offset + - completion_end_offset + properties: + completion_start_offset: + type: integer + format: int32 + description: Offset of the UTF32 code point which begins the span. + completion_end_offset: + type: integer + format: int32 + description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. + description: A representation of a span of completion text as used by Azure OpenAI content filter results. + AzureContentFilterCompletionTextSpanDetectionResult: + type: object + required: + - filtered + - detected + - details + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + details: + type: array + items: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' + description: Detailed information about the detected completion text spans. AzureContentFilterDetectionResult: type: object required: @@ -587,6 +620,92 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + ungrounded_material: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' + description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -1053,66 +1172,14 @@ components: type: object required: - id - - choices - created - model - object + - choices properties: id: type: string description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. created: type: integer format: unixtime @@ -1140,6 +1207,10 @@ components: description: The object type, which is always `chat.completion`. usage: $ref: '#/components/schemas/OpenAI.CompletionUsage' + choices: + type: array + items: + $ref: '#/components/schemas/AzureCreateChatCompletionResponseChoice' prompt_filter_results: type: array items: @@ -1160,6 +1231,60 @@ components: description: |- The extended top-level chat completion response model for the Azure OpenAI service. This model adds Responsible AI content filter annotations for prompt input. + AzureCreateChatCompletionResponseChoice: + type: object + required: + - finish_reason + - index + - message + - logprobs + - content_filter_results + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForChoice' + description: The Responsible AI content filter annotations associated with the choice. AzureImage: type: object required: @@ -1399,30 +1524,6 @@ components: items: $ref: '#/components/schemas/OpenAI.ChatCompletionMessageToolCall' description: The tool calls generated by the model, such as function calls. - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 - CreateMessageRequestAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools ElasticsearchChatDataSource: type: object required: @@ -1521,22 +1622,6 @@ components: description: The parameter information to control the use of the Elasticsearch data source. allOf: - $ref: '#/components/schemas/AzureChatDataSource' - MessageObjectAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true MongoDBChatDataSource: type: object required: @@ -2242,9 +2327,10 @@ components: format: float description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' + type: array + items: + type: integer + format: int32 nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2513,9 +2599,24 @@ components: $ref: '#/components/schemas/OpenAI.MessageContent' x-oaiExpandable: true attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: @@ -2905,9 +3006,21 @@ components: nullable: true description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true nullable: true description: A list of files attached to the message, and the tools they were added to. metadata: diff --git a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml index ac93169f9..63e6db15c 100644 --- a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml @@ -515,6 +515,39 @@ components: - id description: The pairs of individual blocklist IDs and whether they resulted in a filtering action. description: A collection of true/false filtering results for configured custom blocklists. + AzureContentFilterCompletionTextSpan: + type: object + required: + - completion_start_offset + - completion_end_offset + properties: + completion_start_offset: + type: integer + format: int32 + description: Offset of the UTF32 code point which begins the span. + completion_end_offset: + type: integer + format: int32 + description: Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. + description: A representation of a span of completion text as used by Azure OpenAI content filter results. + AzureContentFilterCompletionTextSpanDetectionResult: + type: object + required: + - filtered + - detected + - details + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + details: + type: array + items: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpan' + description: Detailed information about the detected completion text spans. AzureContentFilterDetectionResult: type: object required: @@ -587,6 +620,92 @@ components: A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself. description: A content filter result for an image generation operation's output response content. + AzureContentFilterResultForChoice: + type: object + properties: + sexual: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + hate: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + language with reference to a person or identity group based on certain differentiating attributes of these groups + including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + religion, immigration status, ability status, personal appearance, and body size. + violence: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + someone or something; describes weapons, guns and related entities, such as manufactures, associations, + legislation, and so on. + self_harm: + allOf: + - $ref: '#/components/schemas/AzureContentFilterSeverityResult' + description: |- + A content filter category that describes language related to physical actions intended to purposely hurt, injure, + damage one's body or kill oneself. + profanity: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: |- + A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + content. + custom_blocklists: + allOf: + - $ref: '#/components/schemas/AzureContentFilterBlocklistResult' + description: A collection of binary filtering outcomes for configured custom blocklists. + error: + type: object + properties: + code: + type: integer + format: int32 + description: A distinct, machine-readable code associated with the error. + message: + type: string + description: A human-readable message associated with the error. + required: + - code + - message + description: If present, details about an error that prevented content filtering from completing its evaluation. + protected_material_text: + allOf: + - $ref: '#/components/schemas/AzureContentFilterDetectionResult' + description: A detection result that describes a match against text protected under copyright or other status. + protected_material_code: + type: object + properties: + filtered: + type: boolean + description: Whether the content detection resulted in a content filtering action. + detected: + type: boolean + description: Whether the labeled content category was detected in the content. + citation: + type: object + properties: + license: + type: string + description: The name or identifier of the license associated with the detection. + URL: + type: string + format: uri + description: The URL associated with the license. + description: If available, the citation details describing the associated license and its location. + required: + - filtered + - detected + description: A detection result that describes a match against licensed code or other protected source material. + ungrounded_material: + $ref: '#/components/schemas/AzureContentFilterCompletionTextSpanDetectionResult' + description: A content filter result for a single response item produced by a generative AI system. AzureContentFilterResultForPrompt: type: object properties: @@ -1103,66 +1222,14 @@ components: type: object required: - id - - choices - created - model - object + - choices properties: id: type: string description: A unique identifier for the chat completion. - choices: - type: array - items: - type: object - properties: - finish_reason: - type: string - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - description: |- - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - index: - type: integer - format: int32 - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' - logprobs: - type: object - properties: - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message content tokens with log probability information. - readOnly: true - refusal: - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' - nullable: true - description: A list of message refusal tokens with log probability information. - readOnly: true - required: - - content - - refusal - nullable: true - description: Log probability information for the choice. - required: - - finish_reason - - index - - message - - logprobs - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. created: type: integer format: unixtime @@ -1190,6 +1257,10 @@ components: description: The object type, which is always `chat.completion`. usage: $ref: '#/components/schemas/OpenAI.CompletionUsage' + choices: + type: array + items: + $ref: '#/components/schemas/AzureCreateChatCompletionResponseChoice' prompt_filter_results: type: array items: @@ -1210,6 +1281,60 @@ components: description: |- The extended top-level chat completion response model for the Azure OpenAI service. This model adds Responsible AI content filter annotations for prompt input. + AzureCreateChatCompletionResponseChoice: + type: object + required: + - finish_reason + - index + - message + - logprobs + - content_filter_results + properties: + finish_reason: + type: string + enum: + - stop + - length + - tool_calls + - content_filter + - function_call + description: |- + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + index: + type: integer + format: int32 + description: The index of the choice in the list of choices. + message: + $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + logprobs: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message content tokens with log probability information. + readOnly: true + refusal: + type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionTokenLogprob' + nullable: true + description: A list of message refusal tokens with log probability information. + readOnly: true + required: + - content + - refusal + nullable: true + description: Log probability information for the choice. + content_filter_results: + allOf: + - $ref: '#/components/schemas/AzureContentFilterResultForChoice' + description: The Responsible AI content filter annotations associated with the choice. AzureImage: type: object required: @@ -1467,30 +1592,6 @@ components: use: `["text", "audio"]` - ChatCompletionTokenLogprobBytes: - type: array - items: - type: integer - format: int32 - CreateMessageRequestAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools ElasticsearchChatDataSource: type: object required: @@ -1589,22 +1690,6 @@ components: description: The parameter information to control the use of the Elasticsearch data source. allOf: - $ref: '#/components/schemas/AzureChatDataSource' - MessageObjectAttachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' - - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true MongoDBChatDataSource: type: object required: @@ -2310,9 +2395,10 @@ components: format: float description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytes' + type: array + items: + type: integer + format: int32 nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -2581,9 +2667,24 @@ components: $ref: '#/components/schemas/OpenAI.MessageContent' x-oaiExpandable: true attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: @@ -2973,9 +3074,21 @@ components: nullable: true description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachments' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolsCode' + - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true nullable: true description: A list of files attached to the message, and the tools they were added to. metadata: diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index c309c0632..fb48bcfd4 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -4451,9 +4451,10 @@ components: format: float description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + type: array + items: + type: integer + format: int32 nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -4480,11 +4481,6 @@ components: - logprob - bytes description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. - ChatCompletionTokenLogprobBytesItem: - type: array - items: - type: integer - format: int32 ChatCompletionTool: type: object required: @@ -5895,9 +5891,9 @@ components: See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. integrations: - type: object - allOf: - - $ref: '#/components/schemas/CreateFineTuningJobRequestIntegrations' + type: array + items: + $ref: '#/components/schemas/CreateFineTuningJobRequestIntegration' nullable: true description: A list of integrations to enable for your fine-tuning job. seed: @@ -5934,10 +5930,6 @@ components: propertyName: type mapping: wandb: '#/components/schemas/CreateFineTuningJobRequestWandbIntegration' - CreateFineTuningJobRequestIntegrations: - type: array - items: - $ref: '#/components/schemas/CreateFineTuningJobRequestIntegration' CreateFineTuningJobRequestWandbIntegration: type: object required: @@ -6151,9 +6143,24 @@ components: $ref: '#/components/schemas/MessageContent' x-oaiExpandable: true attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachmentsItem' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: @@ -6163,25 +6170,6 @@ components: nullable: true description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. x-oaiTypeLabel: map - CreateMessageRequestAttachmentsItem: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools CreateModerationRequest: type: object required: @@ -6586,17 +6574,18 @@ components: nullable: true description: Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions. additional_messages: - type: object - allOf: - - $ref: '#/components/schemas/CreateRunRequestAdditional_messages' + type: array + items: + $ref: '#/components/schemas/CreateMessageRequest' nullable: true description: Adds additional messages to the thread before creating the run. tools: - type: object - allOf: - - $ref: '#/components/schemas/CreateRunRequestTools' + type: array + items: + $ref: '#/components/schemas/AssistantToolDefinition' nullable: true description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + x-oaiExpandable: true metadata: type: object additionalProperties: @@ -6656,16 +6645,6 @@ components: allOf: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' nullable: true - CreateRunRequestAdditional_messages: - type: array - items: - $ref: '#/components/schemas/CreateMessageRequest' - CreateRunRequestTools: - type: array - items: - $ref: '#/components/schemas/AssistantToolDefinition' - maxItems: 20 - x-oaiExpandable: true CreateSpeechRequest: type: object required: @@ -6764,9 +6743,9 @@ components: nullable: true description: Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis. tools: - type: object - allOf: - - $ref: '#/components/schemas/CreateThreadAndRunRequestTools' + type: array + items: + $ref: '#/components/schemas/AssistantToolDefinition' nullable: true description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. tool_resources: @@ -6845,11 +6824,6 @@ components: allOf: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' nullable: true - CreateThreadAndRunRequestTools: - type: array - items: - $ref: '#/components/schemas/AssistantToolDefinition' - maxItems: 20 CreateThreadRequest: type: object properties: @@ -7743,11 +7717,12 @@ components: nullable: true description: The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents). integrations: - type: object - allOf: - - $ref: '#/components/schemas/FineTuningJobIntegrationsItem' + type: array + items: + $ref: '#/components/schemas/FineTuningIntegration' nullable: true description: A list of integrations to enable for this fine-tuning job. + x-oaiExpandable: true seed: type: integer format: int32 @@ -7871,12 +7846,6 @@ components: type: string enum: - auto - FineTuningJobIntegrationsItem: - type: array - items: - $ref: '#/components/schemas/FineTuningIntegration' - maxItems: 5 - x-oaiExpandable: true FunctionObject: type: object required: @@ -8914,9 +8883,21 @@ components: nullable: true description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachmentsItem' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true nullable: true description: A list of files attached to the message, and the tools they were added to. metadata: @@ -8928,22 +8909,6 @@ components: x-oaiTypeLabel: map readOnly: true description: Represents a message within a [thread](/docs/api-reference/threads). - MessageObjectAttachmentsItem: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true MessageRequestContentTextObject: type: object required: diff --git a/.typespec.azure/chat/models.response.tsp b/.typespec.azure/chat/models.response.tsp index 79db7e221..601c9a35e 100644 --- a/.typespec.azure/chat/models.response.tsp +++ b/.typespec.azure/chat/models.response.tsp @@ -19,12 +19,26 @@ namespace AzureOpenAI; AzureOpenAIServiceApiVersion.v2024_08_01_preview ); +model AzureCreateChatCompletionResponseChoice { + ...OpenAI.CreateChatCompletionResponseChoice; + + /** + * The Responsible AI content filter annotations associated with the choice. + */ + content_filter_results: AzureContentFilterResultForChoice; +} + +@withoutOmittedProperties("choices") +model CreateChatCompletionResponseCommonBase + is OpenAI.CreateChatCompletionResponse; + /** * The extended top-level chat completion response model for the Azure OpenAI service. * This model adds Responsible AI content filter annotations for prompt input. */ model AzureCreateChatCompletionResponse { - ...OpenAI.CreateChatCompletionResponse; + ...CreateChatCompletionResponseCommonBase; + choices: AzureCreateChatCompletionResponseChoice[]; /** * The Responsible AI content filter annotations associated with prompt inputs into chat completions. diff --git a/.typespec/administration/models.tsp b/.typespec/administration/models.tsp index e9c6c9061..2e76978a5 100644 --- a/.typespec/administration/models.tsp +++ b/.typespec/administration/models.tsp @@ -7,6 +7,24 @@ using TypeSpec.OpenAPI; namespace OpenAI; +// Tool generated type. Extracts from Invite.projects +alias InviteProject = { + /** Project's public ID */ + id?: string; + + /** Project membership role */ + role?: "member" | "owner"; +}; + +// Tool generated type. Extracts from InviteRequest.projects +alias InviteRequestProject = { + /** Project's public ID */ + id: string; + + /** Project membership role */ + role: "member" | "owner"; +}; + /** The service account that performed the audit logged action. */ model AuditLogActorServiceAccount { /** The service account id. */ @@ -460,13 +478,7 @@ model Invite { accepted_at?: utcDateTime; /** The projects that were granted membership upon acceptance of the invite. */ - projects?: { - /** Project's public ID */ - id?: string; - - /** Project membership role */ - role?: "member" | "owner"; - }[]; + projects?: InviteProject[]; } model InviteListResponse { @@ -503,13 +515,7 @@ model InviteRequest { role: "reader" | "owner"; /** An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. */ - projects?: { - /** Project's public ID */ - id: string; - - /** Project membership role */ - role: "member" | "owner"; - }[]; + projects?: InviteRequestProject[]; } model InviteDeleteResponse { diff --git a/.typespec/batch/models.tsp b/.typespec/batch/models.tsp index 7e6aaf2eb..9ef85b600 100644 --- a/.typespec/batch/models.tsp +++ b/.typespec/batch/models.tsp @@ -7,6 +7,21 @@ using TypeSpec.OpenAPI; namespace OpenAI; +// Tool generated type. Extracts from Batch.errors.data +alias BatchErrorsData = { + /** An error code identifying the error type. */ + code?: string; + + /** A human-readable message providing more details about the error. */ + message?: string; + + /** The name of the parameter that caused the error, if applicable. */ + param?: string | null; + + /** The line number of the input file where the error occurred, if applicable. */ + line?: int32 | null; +}; + model Batch { id: string; @@ -25,19 +40,7 @@ model Batch { """) object?: "list"; - data?: { - /** An error code identifying the error type. */ - code?: string; - - /** A human-readable message providing more details about the error. */ - message?: string; - - /** The name of the parameter that caused the error, if applicable. */ - param?: string | null; - - /** The line number of the input file where the error occurred, if applicable. */ - line?: int32 | null; - }[]; + data?: BatchErrorsData[]; }; /** The ID of the input file for the batch. */ diff --git a/.typespec/chat/models.tsp b/.typespec/chat/models.tsp index d28f4413a..b0767089a 100644 --- a/.typespec/chat/models.tsp +++ b/.typespec/chat/models.tsp @@ -10,8 +10,103 @@ using TypeSpec.OpenAPI; namespace OpenAI; -// Tool generated type. Extracts ChatCompletionTokenLogprob.bytes -model ChatCompletionTokenLogprobBytes is int32[]; +// Tool generated type. Extracts from CreateChatCompletionResponse.choices +alias CreateChatCompletionResponseChoice = { + @doc(""" + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + """) + finish_reason: + | "stop" + | "length" + | "tool_calls" + | "content_filter" + | "function_call"; + + /** The index of the choice in the list of choices. */ + index: int32; + + message: ChatCompletionResponseMessage; + + /** Log probability information for the choice. */ + logprobs: { + // Tool customization: Apply read-only visibility via annotation + /** A list of message content tokens with log probability information. */ + @visibility("read") + content: ChatCompletionTokenLogprob[] | null; + + // Tool customization: Apply read-only visibility via annotation + /** A list of message refusal tokens with log probability information. */ + @visibility("read") + refusal: ChatCompletionTokenLogprob[] | null; + } | null; +}; + +// Tool generated type. Extracts from CreateChatCompletionFunctionResponse.choices +alias CreateChatCompletionFunctionResponseChoice = { + @doc(""" + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function. + """) + finish_reason: "stop" | "length" | "function_call" | "content_filter"; + + /** The index of the choice in the list of choices. */ + index: int32; + + message: ChatCompletionResponseMessage; +}; + +// Tool generated type. Extracts from ChatCompletionTokenLogprob.top_logprobs +alias ChatCompletionTokenLogprobTopLogprob = { + /** The token. */ + token: string; + + @doc(""" + The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + """) + logprob: float32; + + @doc(""" + A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + """) + bytes: int32[] | null; +}; + +// Tool generated type. Extracts from CreateChatCompletionStreamResponse.choices +alias CreateChatCompletionStreamResponseChoice = { + delta: ChatCompletionStreamResponseDelta; + + /** Log probability information for the choice. */ + logprobs?: { + // Tool customization: Apply read-only visibility via annotation + /** A list of message content tokens with log probability information. */ + @visibility("read") + content: ChatCompletionTokenLogprob[] | null; + + // Tool customization: Apply read-only visibility via annotation + /** A list of message refusal tokens with log probability information. */ + @visibility("read") + refusal: ChatCompletionTokenLogprob[] | null; + } | null; + + @doc(""" + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + """) + finish_reason: + | "stop" + | "length" + | "tool_calls" + | "content_filter" + | "function_call" + | null; + + /** The index of the choice in the list of choices. */ + index: int32; +}; model CreateChatCompletionRequest { /** @@ -309,40 +404,10 @@ model CreateChatCompletionResponse { /** A unique identifier for the chat completion. */ id: string; - // Tool customization: Apply read-only visibility to inner logprobs types @doc(""" A list of chat completion choices. Can be more than one if `n` is greater than 1. """) - choices: { - @doc(""" - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - """) - finish_reason: - | "stop" - | "length" - | "tool_calls" - | "content_filter" - | "function_call"; - - /** The index of the choice in the list of choices. */ - index: int32; - - message: ChatCompletionResponseMessage; - - /** Log probability information for the choice. */ - logprobs: { - /** A list of message content tokens with log probability information. */ - @visibility("read") - content: ChatCompletionTokenLogprob[] | null; - - /** A list of message refusal tokens with log probability information. */ - @visibility("read") - refusal: ChatCompletionTokenLogprob[] | null; - } | null; - }[]; + choices: CreateChatCompletionResponseChoice[]; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime /** The Unix timestamp (in seconds) of when the chat completion was created. */ @@ -675,17 +740,7 @@ model CreateChatCompletionFunctionResponse { @doc(""" A list of chat completion choices. Can be more than one if `n` is greater than 1. """) - choices: { - @doc(""" - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function. - """) - finish_reason: "stop" | "length" | "function_call" | "content_filter"; - - /** The index of the choice in the list of choices. */ - index: int32; - - message: ChatCompletionResponseMessage; - }[]; + choices: CreateChatCompletionFunctionResponseChoice[]; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime /** The Unix timestamp (in seconds) of when the chat completion was created. */ @@ -776,25 +831,12 @@ model ChatCompletionTokenLogprob { @doc(""" A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. """) - bytes: ChatCompletionTokenLogprobBytes | null; + bytes: int32[] | null; @doc(""" List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. """) - top_logprobs: { - /** The token. */ - token: string; - - @doc(""" - The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - """) - logprob: float32; - - @doc(""" - A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - """) - bytes: int32[] | null; - }[]; + top_logprobs: ChatCompletionTokenLogprobTopLogprob[]; } @doc(""" @@ -869,42 +911,11 @@ model CreateChatCompletionStreamResponse { /** A unique identifier for the chat completion. Each chunk has the same ID. */ id: string; - // Tool customization: Apply read-only visibility to inner logprobs types @doc(""" A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the last chunk if you set `stream_options: {"include_usage": true}`. """) - choices: { - delta: ChatCompletionStreamResponseDelta; - - /** Log probability information for the choice. */ - logprobs?: { - /** A list of message content tokens with log probability information. */ - @visibility("read") - content: ChatCompletionTokenLogprob[] | null; - - /** A list of message refusal tokens with log probability information. */ - @visibility("read") - refusal: ChatCompletionTokenLogprob[] | null; - } | null; - - @doc(""" - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - """) - finish_reason: - | "stop" - | "length" - | "tool_calls" - | "content_filter" - | "function_call" - | null; - - /** The index of the choice in the list of choices. */ - index: int32; - }[]; + choices: CreateChatCompletionStreamResponseChoice[]; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime /** The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp. */ diff --git a/.typespec/completions/models.tsp b/.typespec/completions/models.tsp index 4ac388561..4b8822bd2 100644 --- a/.typespec/completions/models.tsp +++ b/.typespec/completions/models.tsp @@ -9,6 +9,25 @@ using TypeSpec.OpenAPI; namespace OpenAI; +// Tool generated type. Extracts from CreateCompletionResponse.choices +alias CreateCompletionResponseChoice = { + @doc(""" + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + or `content_filter` if content was omitted due to a flag from our content filters. + """) + finish_reason: "stop" | "length" | "content_filter"; + + index: int32; + logprobs: { + text_offset?: int32[]; + token_logprobs?: float32[]; + tokens?: string[]; + top_logprobs?: Record[]; + } | null; + text: string; +}; + model CreateCompletionRequest { /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. */ @extension("x-oaiTypeLabel", "string") @@ -141,23 +160,7 @@ model CreateCompletionResponse { id: string; /** The list of completion choices the model generated for the input prompt. */ - choices: { - @doc(""" - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - or `content_filter` if content was omitted due to a flag from our content filters. - """) - finish_reason: "stop" | "length" | "content_filter"; - - index: int32; - logprobs: { - text_offset?: int32[]; - token_logprobs?: float32[]; - tokens?: string[]; - top_logprobs?: Record[]; - } | null; - text: string; - }[]; + choices: CreateCompletionResponseChoice[]; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime /** The Unix timestamp (in seconds) of when the completion was created. */ diff --git a/.typespec/fine-tuning/models.tsp b/.typespec/fine-tuning/models.tsp index d162e6526..62f511e16 100644 --- a/.typespec/fine-tuning/models.tsp +++ b/.typespec/fine-tuning/models.tsp @@ -11,15 +11,6 @@ using TypeSpec.OpenAPI; namespace OpenAI; -// Tool generated type. Extracts CreateFineTuningJobRequest.integrations -model CreateFineTuningJobRequestIntegrations - is CreateFineTuningJobRequestIntegration[]; - -// Tool generated type. Extracts FineTuningJob.integrations -@maxItems(5) -@extension("x-oaiExpandable", true) -model FineTuningJobIntegrations is FineTuningIntegration[]; - model CreateFineTuningJobRequest { /** * The name of the model to fine-tune. You can select one of the @@ -96,7 +87,7 @@ model CreateFineTuningJobRequest { // Tool customization: establish a discriminated type basis /** A list of integrations to enable for your fine-tuning job. */ - integrations?: CreateFineTuningJobRequestIntegrations | null; + integrations?: CreateFineTuningJobRequestIntegration[] | null; /** * The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. @@ -226,7 +217,9 @@ model FineTuningJob { validation_file: string | null; /** A list of integrations to enable for this fine-tuning job. */ - integrations?: FineTuningJobIntegrations | null; + // !no_nullable! @maxItems(5) + @extension("x-oaiExpandable", true) + integrations?: FineTuningIntegration[] | null; /** The seed used for the fine-tuning job. */ seed: int32; diff --git a/.typespec/messages/models.tsp b/.typespec/messages/models.tsp index c4c40d32f..68d722e64 100644 --- a/.typespec/messages/models.tsp +++ b/.typespec/messages/models.tsp @@ -10,27 +10,25 @@ using TypeSpec.OpenAPI; namespace OpenAI; -// Tool generated type. Extracts CreateMessageRequest.attachments -model CreateMessageRequestAttachments - is { - /** The ID of the file to attach to the message. */ - file_id: string; +// Tool generated type. Extracts from CreateMessageRequest.attachments +alias CreateMessageRequestAttachment = { + /** The ID of the file to attach to the message. */ + file_id: string; - /** The tools to add this file to. */ - @extension("x-oaiExpandable", true) - tools: (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; - }[]; + /** The tools to add this file to. */ + @extension("x-oaiExpandable", true) + tools: (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; +}; -// Tool generated type. Extracts MessageObject.attachments -model MessageObjectAttachments - is { - /** The ID of the file to attach to the message. */ - file_id?: string; +// Tool generated type. Extracts from MessageObject.attachments +alias MessageObjectAttachment = { + /** The ID of the file to attach to the message. */ + file_id?: string; - /** The tools to add this file to. */ - @extension("x-oaiExpandable", true) - tools?: (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; - }[]; + /** The tools to add this file to. */ + @extension("x-oaiExpandable", true) + tools?: (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; +}; model CreateMessageRequest { @doc(""" @@ -45,7 +43,7 @@ model CreateMessageRequest { content: MessageContent[]; /** A list of files attached to the message, and the tools they should be added to. */ - attachments?: CreateMessageRequestAttachments | null; + attachments?: CreateMessageRequestAttachment[] | null; // Tool customization: specialize known metadata string maps /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ @@ -139,7 +137,7 @@ model MessageObject { run_id: string | null; /** A list of files attached to the message, and the tools they were added to. */ - attachments: MessageObjectAttachments | null; + attachments: MessageObjectAttachment[] | null; // Tool customization: specialize known metadata string maps /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ diff --git a/.typespec/runs/models.tsp b/.typespec/runs/models.tsp index 4e23d851c..225d65761 100644 --- a/.typespec/runs/models.tsp +++ b/.typespec/runs/models.tsp @@ -13,17 +13,25 @@ using TypeSpec.OpenAPI; namespace OpenAI; -// Tool generated type. Extracts CreateRunRequest.additional_messages -model CreateRunRequestAdditional_messages is CreateMessageRequest[]; +// Tool generated type. Extracts from SubmitToolOutputsRunRequest.tool_outputs +alias SubmitToolOutputsRunRequestToolOutput = { + @doc(""" + The ID of the tool call in the `required_action` object within the run object the output is being submitted for. + """) + tool_call_id?: string; -// Tool generated type. Extracts CreateRunRequest.tools -@maxItems(20) -@extension("x-oaiExpandable", true) -model CreateRunRequestTools is AssistantToolDefinition[]; + /** The output of the tool call to be submitted to continue the run. */ + output?: string; +}; -// Tool generated type. Extracts CreateThreadAndRunRequest.tools -@maxItems(20) -model CreateThreadAndRunRequestTools is AssistantToolDefinition[]; +// Tool generated type. Extracts from RunStepDetailsToolCallsFileSearchResultObject.content +alias RunStepDetailsToolCallsFileSearchResultObjectContent = { + /** The type of the content. */ + type?: "text"; + + /** The text content of the file. */ + text?: string; +}; model CreateRunRequest { /** The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. */ @@ -66,11 +74,13 @@ model CreateRunRequest { additional_instructions?: string | null; /** Adds additional messages to the thread before creating the run. */ - additional_messages?: CreateRunRequestAdditional_messages | null; + additional_messages?: CreateMessageRequest[] | null; // Tool customization: use common model base for tool definitions /** Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ - tools?: CreateRunRequestTools | null; + // !no_nullable! @maxItems(20) + @extension("x-oaiExpandable", true) + tools?: AssistantToolDefinition[] | null; // Tool customization: specialize known metadata string maps /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ @@ -162,7 +172,8 @@ model CreateThreadAndRunRequest { // Tool customization: use common model base for tool definitions /** Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ - tools?: CreateThreadAndRunRequestTools | null; + // !no_nullable! @maxItems(20) + tools?: AssistantToolDefinition[] | null; @doc(""" A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. @@ -224,15 +235,7 @@ model CreateThreadAndRunRequest { model SubmitToolOutputsRunRequest { /** A list of tools for which the outputs are being submitted. */ - tool_outputs: { - @doc(""" - The ID of the tool call in the `required_action` object within the run object the output is being submitted for. - """) - tool_call_id?: string; - - /** The output of the tool call to be submitted to continue the run. */ - output?: string; - }[]; + tool_outputs: SubmitToolOutputsRunRequestToolOutput[]; @doc(""" If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. @@ -393,13 +396,7 @@ model RunStepDetailsToolCallsFileSearchResultObject { score: float32; /** The content of the result that was found. The content is only included if requested via the include query parameter. */ - content?: { - /** The type of the content. */ - type?: "text"; - - /** The text content of the file. */ - text?: string; - }[]; + content?: RunStepDetailsToolCallsFileSearchResultObjectContent[]; } // Tool customization: apply custom, common base type to union items diff --git a/README.md b/README.md index dddc918d7..d01a78321 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Date: Wed Jan 22 19:03:08 2025 +0000 Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk ``` -commit f9e16b8f3216c20b03fb3dd0083e3b03a11bce34 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) +commit 895db04b811623599de66b00ea625edee392a1e0 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) Author: Travis Wilson -Date: Mon Jan 27 17:36:50 2025 -0800 +Date: Thu Jan 30 18:48:34 2025 -0800 ``` There are some deltas: From 229123a8351aae61999b0e77ad7a4d95743f1563 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Fri, 31 Jan 2025 16:47:57 -0800 Subject: [PATCH 33/44] merge, apply latest spec and tool updates --- .dotnet/CHANGELOG.md | 6 +- .dotnet/api/OpenAI.netstandard2.0.cs | 20 +- .../Custom/Chat/Internal/GeneratorStubs.cs | 5 +- .../Internal/GeneratorStubs.cs | 3 + .../Internal/InternalRealtimeResponse.cs | 9 + .../AssistantCreationOptions.Serialization.cs | 25 +- .../Models/AssistantCreationOptions.cs | 2 +- ...istantModificationOptions.Serialization.cs | 25 +- .../Models/AssistantModificationOptions.cs | 2 +- .../ChatCompletionOptions.Serialization.cs | 25 +- ...nversationResponseOptions.Serialization.cs | 64 +-- .../Models/ConversationResponseOptions.cs | 6 +- .../Models/InternalBatchJob.Serialization.cs | 7 +- .../src/Generated/Models/InternalBatchJob.cs | 5 +- ...nternalCreateBatchRequest.Serialization.cs | 25 +- ...nternalCreateChatCompletionRequestModel.cs | 6 + ...CreateThreadAndRunRequest.Serialization.cs | 25 +- .../InternalCreateThreadAndRunRequest.cs | 2 +- ...nternalFunctionParameters.Serialization.cs | 120 ---- .../Models/InternalFunctionParameters.cs | 33 -- .../InternalRealtimeResponse.Serialization.cs | 120 +++- .../Models/InternalRealtimeResponse.cs | 19 +- .../InternalRealtimeResponseModality.cs | 44 ++ ...ternalRealtimeResponseOutputAudioFormat.cs | 47 ++ .../Models/InternalRealtimeResponseVoice.cs | 62 ++ .../MessageCreationOptions.Serialization.cs | 25 +- .../Models/MessageCreationOptions.cs | 2 +- ...essageModificationOptions.Serialization.cs | 25 +- .../Models/MessageModificationOptions.cs | 2 +- .../RunCreationOptions.Serialization.cs | 25 +- .../RunModificationOptions.Serialization.cs | 25 +- .../Models/RunModificationOptions.cs | 2 +- .../ThreadCreationOptions.Serialization.cs | 25 +- .../Generated/Models/ThreadCreationOptions.cs | 2 +- ...ThreadModificationOptions.Serialization.cs | 25 +- .../Models/ThreadModificationOptions.cs | 2 +- ...ectorStoreCreationOptions.Serialization.cs | 25 +- .../Models/VectorStoreCreationOptions.cs | 2 +- ...rStoreModificationOptions.Serialization.cs | 25 +- .../Models/VectorStoreModificationOptions.cs | 2 +- .dotnet/src/Generated/OpenAIModelFactory.cs | 4 +- .openapi3/openapi3-openai.yaml | 534 +++++++++++++----- .typespec/administration/models.tsp | 34 +- .typespec/assistants/custom.tsp | 8 +- .typespec/assistants/models.tsp | 15 +- .typespec/audio/models.tsp | 4 +- .typespec/batch/models.tsp | 36 +- .typespec/batch/operations.tsp | 2 +- .typespec/chat/models.tsp | 207 +++---- .typespec/common/models.tsp | 48 +- .typespec/completions/models.tsp | 37 +- .typespec/fine-tuning/models.tsp | 15 +- .typespec/messages/models.tsp | 54 +- .typespec/realtime/models.tsp | 92 ++- .typespec/runs/models.tsp | 80 +-- .typespec/threads/custom.tsp | 8 +- .typespec/threads/models.tsp | 16 +- .typespec/vector-stores/models.tsp | 17 +- README.md | 8 +- openapi3-original.yaml | 369 ++++++------ 60 files changed, 1378 insertions(+), 1131 deletions(-) delete mode 100644 .dotnet/src/Generated/Models/InternalFunctionParameters.Serialization.cs delete mode 100644 .dotnet/src/Generated/Models/InternalFunctionParameters.cs create mode 100644 .dotnet/src/Generated/Models/InternalRealtimeResponseModality.cs create mode 100644 .dotnet/src/Generated/Models/InternalRealtimeResponseOutputAudioFormat.cs create mode 100644 .dotnet/src/Generated/Models/InternalRealtimeResponseVoice.cs diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index cff7d3a34..5c9047c2a 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -14,7 +14,11 @@ - For `o1` and later models with reasoning capabilities: - The new `DeveloperChatMessage`, which replaces `SystemChatMessage`, can be used to provide instructions to the model - `ChatCompletionOptions` can specify a `ReasoningEffort` property to adjust the level of token consumption the model will attempt to apply - + +### `[Experimental]` Breaking changes + +- The `IDictionary Metadata` property in several request options types in the Assistants and RealtimeConversation areas have had their setters removed, aligning them with other request use of collections. The dictionaries remain writeable and use both initializer syntax and range copies to produce the same effect. + ## 2.1.0 (2024-12-04) ### Features added diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 8260f96da..95926799e 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -224,7 +224,7 @@ public class AssistantCollectionOptions { public class AssistantCreationOptions : IJsonModel, IPersistableModel { public string Description { get; set; } public string Instructions { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public string Name { get; set; } public float? NucleusSamplingFactor { get; set; } public AssistantResponseFormat ResponseFormat { get; set; } @@ -244,7 +244,7 @@ public class AssistantModificationOptions : IJsonModel DefaultTools { get; } public string Description { get; set; } public string Instructions { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public string Model { get; set; } public string Name { get; set; } public float? NucleusSamplingFactor { get; set; } @@ -406,7 +406,7 @@ public class MessageCreationAttachment : IJsonModel, } public class MessageCreationOptions : IJsonModel, IPersistableModel { public IList Attachments { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public static explicit operator MessageCreationOptions(ClientResult result); public static implicit operator BinaryContent(MessageCreationOptions messageCreationOptions); } @@ -444,7 +444,7 @@ public enum MessageImageDetail { High = 2 } public class MessageModificationOptions : IJsonModel, IPersistableModel { - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public static explicit operator MessageModificationOptions(ClientResult result); public static implicit operator BinaryContent(MessageModificationOptions messageModificationOptions); } @@ -559,7 +559,7 @@ public class RunIncompleteDetails : IJsonModel, IPersistab public override readonly string ToString(); } public class RunModificationOptions : IJsonModel, IPersistableModel { - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public static explicit operator RunModificationOptions(ClientResult result); public static implicit operator BinaryContent(RunModificationOptions runModificationOptions); } @@ -809,7 +809,7 @@ public class TextAnnotationUpdate { } public class ThreadCreationOptions : IJsonModel, IPersistableModel { public IList InitialMessages { get; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public ToolResources ToolResources { get; set; } public static explicit operator ThreadCreationOptions(ClientResult result); public static implicit operator BinaryContent(ThreadCreationOptions threadCreationOptions); @@ -842,7 +842,7 @@ public class ThreadMessage : IJsonModel, IPersistableModel, IPersistableModel { - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public ToolResources ToolResources { get; set; } public static explicit operator ThreadModificationOptions(ClientResult result); public static implicit operator BinaryContent(ThreadModificationOptions threadModificationOptions); @@ -2453,7 +2453,7 @@ public class ConversationResponseOptions : IJsonModel Metadata { get; set; } + public IDictionary Metadata { get; } public ConversationAudioFormat? OutputAudioFormat { get; set; } public IList OverrideItems { get; } public float? Temperature { get; set; } @@ -2983,7 +2983,7 @@ public class VectorStoreCreationOptions : IJsonModel public FileChunkingStrategy ChunkingStrategy { get; set; } public VectorStoreExpirationPolicy ExpirationPolicy { get; set; } public IList FileIds { get; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public string Name { get; set; } public static explicit operator VectorStoreCreationOptions(ClientResult result); public static implicit operator BinaryContent(VectorStoreCreationOptions vectorStoreCreationOptions); @@ -3093,7 +3093,7 @@ public class VectorStoreFileCounts : IJsonModel, IPersist } public class VectorStoreModificationOptions : IJsonModel, IPersistableModel { public VectorStoreExpirationPolicy ExpirationPolicy { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public string Name { get; set; } public static explicit operator VectorStoreModificationOptions(ClientResult result); public static implicit operator BinaryContent(VectorStoreModificationOptions vectorStoreModificationOptions); diff --git a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs index 41cf4c062..9170e26d8 100644 --- a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs @@ -36,7 +36,7 @@ internal readonly partial struct InternalChatCompletionResponseMessageRole { } [CodeGenModel("ChatCompletionStreamOptions")] internal partial class InternalChatCompletionStreamOptions { } -[CodeGenModel("ChatCompletionStreamResponseDeltaRole")] +[CodeGenModel("ChatCompletionStreamResponseDeltaRole2")] internal readonly partial struct InternalChatCompletionStreamResponseDeltaRole { } [CodeGenModel("CreateChatCompletionFunctionResponse")] @@ -93,9 +93,6 @@ internal readonly partial struct InternalCreateChatCompletionStreamResponseServi [CodeGenModel("CreateChatCompletionStreamResponseUsage")] internal partial class InternalCreateChatCompletionStreamResponseUsage { } -[CodeGenModel("FunctionParameters")] -internal partial class InternalFunctionParameters { } - [CodeGenModel("CreateChatCompletionRequestModality")] internal readonly partial struct InternalCreateChatCompletionRequestModality { } diff --git a/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs index 10c06a468..d26ba5e9a 100644 --- a/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/RealtimeConversation/Internal/GeneratorStubs.cs @@ -24,11 +24,14 @@ namespace OpenAI.RealtimeConversation; [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseAudioContentPart")] internal partial class InternalRealtimeResponseAudioContentPart { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseFunctionCallItem")] internal partial class InternalRealtimeResponseFunctionCallItem { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseFunctionCallOutputItem")] internal partial class InternalRealtimeResponseFunctionCallOutputItem { } +[Experimental("OPENAI002")][CodeGenModel("RealtimeResponseModality")] internal readonly partial struct InternalRealtimeResponseModality { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseObject")] internal readonly partial struct InternalRealtimeResponseObject { } +[Experimental("OPENAI002")][CodeGenModel("RealtimeResponseOutputAudioFormat")] internal readonly partial struct InternalRealtimeResponseOutputAudioFormat { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseSessionObject")] internal readonly partial struct InternalRealtimeResponseSessionObject { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseStatusDetailsError")] internal partial class InternalRealtimeResponseStatusDetailsError { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseStatusDetailsType")] internal readonly partial struct InternalRealtimeResponseStatusDetailsType { } [Experimental("OPENAI002")][CodeGenModel("RealtimeResponseTextContentPart")] internal partial class InternalRealtimeResponseTextContentPart { } +[Experimental("OPENAI002")][CodeGenModel("RealtimeResponseVoice")] internal readonly partial struct InternalRealtimeResponseVoice { } [Experimental("OPENAI002")][CodeGenModel("RealtimeServerEventConversationCreated")] internal partial class InternalRealtimeServerEventConversationCreated { } [Experimental("OPENAI002")][CodeGenModel("RealtimeServerEventConversationCreatedConversation")] internal partial class InternalRealtimeServerEventConversationCreatedConversation { } [Experimental("OPENAI002")][CodeGenModel("RealtimeServerEventConversationItemInputAudioTranscriptionFailedError")] internal partial class InternalRealtimeServerEventConversationItemInputAudioTranscriptionFailedError { } diff --git a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponse.cs b/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponse.cs index 0c26a8a28..bb6d9f175 100644 --- a/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponse.cs +++ b/.dotnet/src/Custom/RealtimeConversation/Internal/InternalRealtimeResponse.cs @@ -10,4 +10,13 @@ internal partial class InternalRealtimeResponse { [CodeGenMember("Output")] public IReadOnlyList Output { get; } + + [CodeGenMember("Modalities")] + internal IReadOnlyList Modalities { get; } + + [CodeGenMember("Voice")] + public ConversationVoice? Voice { get; } + + [CodeGenMember("OutputAudioFormat")] + public ConversationAudioFormat? OutputAudioFormat { get; } } diff --git a/.dotnet/src/Generated/Models/AssistantCreationOptions.Serialization.cs b/.dotnet/src/Generated/Models/AssistantCreationOptions.Serialization.cs index b74e1cf0e..a6c9bb9e7 100644 --- a/.dotnet/src/Generated/Models/AssistantCreationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/AssistantCreationOptions.Serialization.cs @@ -65,26 +65,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(Temperature) && _additionalBinaryDataProperties?.ContainsKey("temperature") != true) { diff --git a/.dotnet/src/Generated/Models/AssistantCreationOptions.cs b/.dotnet/src/Generated/Models/AssistantCreationOptions.cs index ebc4e3202..0a1f7c5dc 100644 --- a/.dotnet/src/Generated/Models/AssistantCreationOptions.cs +++ b/.dotnet/src/Generated/Models/AssistantCreationOptions.cs @@ -32,7 +32,7 @@ internal AssistantCreationOptions(string name, string description, string instru public string Instructions { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public float? Temperature { get; set; } diff --git a/.dotnet/src/Generated/Models/AssistantModificationOptions.Serialization.cs b/.dotnet/src/Generated/Models/AssistantModificationOptions.Serialization.cs index d60696f6a..7212963c9 100644 --- a/.dotnet/src/Generated/Models/AssistantModificationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/AssistantModificationOptions.Serialization.cs @@ -65,26 +65,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(Temperature) && _additionalBinaryDataProperties?.ContainsKey("temperature") != true) { diff --git a/.dotnet/src/Generated/Models/AssistantModificationOptions.cs b/.dotnet/src/Generated/Models/AssistantModificationOptions.cs index 3019103f5..c9d4cd4c5 100644 --- a/.dotnet/src/Generated/Models/AssistantModificationOptions.cs +++ b/.dotnet/src/Generated/Models/AssistantModificationOptions.cs @@ -39,7 +39,7 @@ internal AssistantModificationOptions(string name, string description, string in public string Instructions { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public float? Temperature { get; set; } diff --git a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs index b137e7f49..3d096db75 100644 --- a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs @@ -252,26 +252,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(StoredOutputEnabled) && _additionalBinaryDataProperties?.ContainsKey("store") != true) { diff --git a/.dotnet/src/Generated/Models/ConversationResponseOptions.Serialization.cs b/.dotnet/src/Generated/Models/ConversationResponseOptions.Serialization.cs index 48aee4803..e7772a67b 100644 --- a/.dotnet/src/Generated/Models/ConversationResponseOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationResponseOptions.Serialization.cs @@ -59,32 +59,30 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(ConversationSelection) && _additionalBinaryDataProperties?.ContainsKey("conversation") != true) { writer.WritePropertyName("conversation"u8); writer.WriteStringValue(ConversationSelection.Value.ToString()); } + if (Optional.IsDefined(MaxOutputTokens) && _additionalBinaryDataProperties?.ContainsKey("max_output_tokens") != true) + { + writer.WritePropertyName("max_output_tokens"u8); + writer.WriteObjectValue(MaxOutputTokens, options); + } if (Optional.IsCollectionDefined(OverrideItems) && _additionalBinaryDataProperties?.ContainsKey("input") != true) { writer.WritePropertyName("input"u8); @@ -115,18 +113,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { JsonSerializer.Serialize(writer, document.RootElement); } -#endif - } - if (Optional.IsDefined(_maxResponseOutputTokens) && _additionalBinaryDataProperties?.ContainsKey("max_response_output_tokens") != true) - { - writer.WritePropertyName("max_response_output_tokens"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(_maxResponseOutputTokens); -#else - using (JsonDocument document = JsonDocument.Parse(_maxResponseOutputTokens)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } #endif } if (true && _additionalBinaryDataProperties != null) @@ -176,10 +162,10 @@ internal static ConversationResponseOptions DeserializeConversationResponseOptio float? temperature = default; IDictionary metadata = default; ResponseConversationSelection? conversationSelection = default; + RealtimeConversation.ConversationMaxTokensChoice maxOutputTokens = default; IList overrideItems = default; IList internalModalities = default; BinaryData internalToolChoice = default; - BinaryData maxResponseOutputTokens = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -259,6 +245,15 @@ internal static ConversationResponseOptions DeserializeConversationResponseOptio conversationSelection = new ResponseConversationSelection(prop.Value.GetString()); continue; } + if (prop.NameEquals("max_output_tokens"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxOutputTokens = RealtimeConversation.ConversationMaxTokensChoice.DeserializeConversationMaxTokensChoice(prop.Value, options); + continue; + } if (prop.NameEquals("input"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) @@ -296,15 +291,6 @@ internal static ConversationResponseOptions DeserializeConversationResponseOptio internalToolChoice = BinaryData.FromString(prop.Value.GetRawText()); continue; } - if (prop.NameEquals("max_response_output_tokens"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - maxResponseOutputTokens = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -318,10 +304,10 @@ internal static ConversationResponseOptions DeserializeConversationResponseOptio temperature, metadata ?? new ChangeTrackingDictionary(), conversationSelection, + maxOutputTokens, overrideItems ?? new ChangeTrackingList(), internalModalities, internalToolChoice, - maxResponseOutputTokens, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/ConversationResponseOptions.cs b/.dotnet/src/Generated/Models/ConversationResponseOptions.cs index 1249e3656..bf44530bc 100644 --- a/.dotnet/src/Generated/Models/ConversationResponseOptions.cs +++ b/.dotnet/src/Generated/Models/ConversationResponseOptions.cs @@ -20,7 +20,7 @@ public ConversationResponseOptions() _internalModalities = new ChangeTrackingList(); } - internal ConversationResponseOptions(string instructions, ConversationVoice? voice, ConversationAudioFormat? outputAudioFormat, IList tools, float? temperature, IDictionary metadata, ResponseConversationSelection? conversationSelection, IList overrideItems, IList internalModalities, BinaryData internalToolChoice, BinaryData maxResponseOutputTokens, IDictionary additionalBinaryDataProperties) + internal ConversationResponseOptions(string instructions, ConversationVoice? voice, ConversationAudioFormat? outputAudioFormat, IList tools, float? temperature, IDictionary metadata, ResponseConversationSelection? conversationSelection, RealtimeConversation.ConversationMaxTokensChoice maxOutputTokens, IList overrideItems, IList internalModalities, BinaryData internalToolChoice, IDictionary additionalBinaryDataProperties) { Instructions = instructions; Voice = voice; @@ -29,10 +29,10 @@ internal ConversationResponseOptions(string instructions, ConversationVoice? voi Temperature = temperature; Metadata = metadata; ConversationSelection = conversationSelection; + MaxOutputTokens = maxOutputTokens; OverrideItems = overrideItems; _internalModalities = internalModalities; _internalToolChoice = internalToolChoice; - _maxResponseOutputTokens = maxResponseOutputTokens; _additionalBinaryDataProperties = additionalBinaryDataProperties; } @@ -46,7 +46,7 @@ internal ConversationResponseOptions(string instructions, ConversationVoice? voi public float? Temperature { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/InternalBatchJob.Serialization.cs b/.dotnet/src/Generated/Models/InternalBatchJob.Serialization.cs index ee8c9a1b2..99da02c43 100644 --- a/.dotnet/src/Generated/Models/InternalBatchJob.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalBatchJob.Serialization.cs @@ -126,9 +126,9 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("request_counts"u8); writer.WriteObjectValue(RequestCounts, options); } - if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) + if (_additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { writer.WritePropertyName("metadata"u8); writer.WriteStartObject(); @@ -351,6 +351,7 @@ internal static InternalBatchJob DeserializeInternalBatchJob(JsonElement element { if (prop.Value.ValueKind == JsonValueKind.Null) { + metadata = new ChangeTrackingDictionary(); continue; } Dictionary dictionary = new Dictionary(); @@ -393,7 +394,7 @@ internal static InternalBatchJob DeserializeInternalBatchJob(JsonElement element cancellingAt, cancelledAt, requestCounts, - metadata ?? new ChangeTrackingDictionary(), + metadata, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/InternalBatchJob.cs b/.dotnet/src/Generated/Models/InternalBatchJob.cs index 0654bf9a2..fcffc3b52 100644 --- a/.dotnet/src/Generated/Models/InternalBatchJob.cs +++ b/.dotnet/src/Generated/Models/InternalBatchJob.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using OpenAI; namespace OpenAI.Batch { @@ -12,7 +11,7 @@ internal partial class InternalBatchJob { private protected IDictionary _additionalBinaryDataProperties; - internal InternalBatchJob(string id, string endpoint, string inputFileId, string completionWindow, InternalBatchStatus status, DateTimeOffset createdAt) + internal InternalBatchJob(string id, string endpoint, string inputFileId, string completionWindow, InternalBatchStatus status, DateTimeOffset createdAt, IDictionary metadata) { Id = id; Endpoint = endpoint; @@ -20,7 +19,7 @@ internal InternalBatchJob(string id, string endpoint, string inputFileId, string CompletionWindow = completionWindow; Status = status; CreatedAt = createdAt; - Metadata = new ChangeTrackingDictionary(); + Metadata = metadata; } internal InternalBatchJob(string id, InternalBatchObject @object, string endpoint, InternalBatchErrors errors, string inputFileId, string completionWindow, InternalBatchStatus status, string outputFileId, string errorFileId, DateTimeOffset createdAt, DateTimeOffset? inProgressAt, DateTimeOffset? expiresAt, DateTimeOffset? finalizingAt, DateTimeOffset? completedAt, DateTimeOffset? failedAt, DateTimeOffset? expiredAt, DateTimeOffset? cancellingAt, DateTimeOffset? cancelledAt, InternalBatchRequestCounts requestCounts, IDictionary metadata, IDictionary additionalBinaryDataProperties) diff --git a/.dotnet/src/Generated/Models/InternalCreateBatchRequest.Serialization.cs b/.dotnet/src/Generated/Models/InternalCreateBatchRequest.Serialization.cs index a9487ca5d..5dc6f5e4f 100644 --- a/.dotnet/src/Generated/Models/InternalCreateBatchRequest.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalCreateBatchRequest.Serialization.cs @@ -48,26 +48,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (true && _additionalBinaryDataProperties != null) { diff --git a/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs b/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs index d4271293a..cf542074f 100644 --- a/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs +++ b/.dotnet/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs @@ -11,6 +11,8 @@ namespace OpenAI.Chat internal readonly partial struct InternalCreateChatCompletionRequestModel : IEquatable { private readonly string _value; + private const string O3MiniValue = "o3-mini"; + private const string O3Mini20250131Value = "o3-mini-2025-01-31"; private const string O1Value = "o1"; private const string O120241217Value = "o1-2024-12-17"; private const string O1PreviewValue = "o1-preview"; @@ -56,6 +58,10 @@ public InternalCreateChatCompletionRequestModel(string value) _value = value; } + public static InternalCreateChatCompletionRequestModel O3Mini { get; } = new InternalCreateChatCompletionRequestModel(O3MiniValue); + + public static InternalCreateChatCompletionRequestModel O3Mini20250131 { get; } = new InternalCreateChatCompletionRequestModel(O3Mini20250131Value); + public static InternalCreateChatCompletionRequestModel O1 { get; } = new InternalCreateChatCompletionRequestModel(O1Value); public static InternalCreateChatCompletionRequestModel O120241217 { get; } = new InternalCreateChatCompletionRequestModel(O120241217Value); diff --git a/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs b/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs index 471899a6b..8a98c8422 100644 --- a/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs @@ -72,26 +72,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(Temperature) && _additionalBinaryDataProperties?.ContainsKey("temperature") != true) { diff --git a/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequest.cs b/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequest.cs index 77bb26a64..237c224ce 100644 --- a/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequest.cs +++ b/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequest.cs @@ -50,7 +50,7 @@ internal InternalCreateThreadAndRunRequest(string assistantId, ThreadCreationOpt public IList Tools { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } public float? Temperature { get; set; } diff --git a/.dotnet/src/Generated/Models/InternalFunctionParameters.Serialization.cs b/.dotnet/src/Generated/Models/InternalFunctionParameters.Serialization.cs deleted file mode 100644 index cf2589d53..000000000 --- a/.dotnet/src/Generated/Models/InternalFunctionParameters.Serialization.cs +++ /dev/null @@ -1,120 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Chat -{ - internal partial class InternalFunctionParameters : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support writing '{format}' format."); - } - foreach (var item in AdditionalProperties) - { - 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 - } - } - - InternalFunctionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - protected virtual InternalFunctionParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFunctionParameters(document.RootElement, options); - } - - internal static InternalFunctionParameters DeserializeInternalFunctionParameters(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IDictionary additionalProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - additionalProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - return new InternalFunctionParameters(additionalProperties); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support writing '{options.Format}' format."); - } - } - - InternalFunctionParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - protected virtual InternalFunctionParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalFunctionParameters(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalFunctionParameters internalFunctionParameters) - { - if (internalFunctionParameters == null) - { - return null; - } - return BinaryContent.Create(internalFunctionParameters, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalFunctionParameters(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalFunctionParameters(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet/src/Generated/Models/InternalFunctionParameters.cs b/.dotnet/src/Generated/Models/InternalFunctionParameters.cs deleted file mode 100644 index 67b1a19c7..000000000 --- a/.dotnet/src/Generated/Models/InternalFunctionParameters.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using OpenAI; - -namespace OpenAI.Chat -{ - internal partial class InternalFunctionParameters - { - private protected IDictionary _additionalBinaryDataProperties; - - public InternalFunctionParameters() - { - _additionalBinaryDataProperties = new ChangeTrackingDictionary(); - } - - internal InternalFunctionParameters(IDictionary additionalProperties) - { - _additionalBinaryDataProperties = additionalProperties; - } - - public IDictionary AdditionalProperties => _additionalBinaryDataProperties; - - internal IDictionary SerializedAdditionalRawData - { - get => _additionalBinaryDataProperties; - set => _additionalBinaryDataProperties = value; - } - } -} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponse.Serialization.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponse.Serialization.cs index f66ba7b1e..13872d7d6 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponse.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponse.Serialization.cs @@ -13,6 +13,10 @@ namespace OpenAI.RealtimeConversation { internal partial class InternalRealtimeResponse : IJsonModel { + internal InternalRealtimeResponse() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -47,9 +51,9 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("status_details"u8); writer.WriteObjectValue(StatusDetails, options); } - if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) + if (_additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { writer.WritePropertyName("metadata"u8); writer.WriteStartObject(); @@ -75,6 +79,28 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("usage"u8); writer.WriteObjectValue(Usage, options); } + if (Optional.IsDefined(ConversationId) && _additionalBinaryDataProperties?.ContainsKey("conversation_id") != true) + { + writer.WritePropertyName("conversation_id"u8); + writer.WriteStringValue(ConversationId); + } + if (Optional.IsDefined(Temperature) && _additionalBinaryDataProperties?.ContainsKey("temperature") != true) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(MaxOutputTokens) && _additionalBinaryDataProperties?.ContainsKey("max_output_tokens") != true) + { + writer.WritePropertyName("max_output_tokens"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(MaxOutputTokens); +#else + using (JsonDocument document = JsonDocument.Parse(MaxOutputTokens)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } if (Optional.IsCollectionDefined(Output) && _additionalBinaryDataProperties?.ContainsKey("output") != true) { writer.WritePropertyName("output"u8); @@ -85,6 +111,26 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WriteEndArray(); } + if (Optional.IsCollectionDefined(Modalities) && _additionalBinaryDataProperties?.ContainsKey("modalities") != true) + { + writer.WritePropertyName("modalities"u8); + writer.WriteStartArray(); + foreach (InternalRealtimeResponseModality item in Modalities) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Voice) && _additionalBinaryDataProperties?.ContainsKey("voice") != true) + { + writer.WritePropertyName("voice"u8); + writer.WriteStringValue(Voice.Value.ToString()); + } + if (Optional.IsDefined(OutputAudioFormat) && _additionalBinaryDataProperties?.ContainsKey("output_audio_format") != true) + { + writer.WritePropertyName("output_audio_format"u8); + writer.WriteStringValue(OutputAudioFormat.Value.ToString()); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -131,7 +177,13 @@ internal static InternalRealtimeResponse DeserializeInternalRealtimeResponse(Jso ConversationStatusDetails statusDetails = default; IDictionary metadata = default; ConversationTokenUsage usage = default; + string conversationId = default; + float? temperature = default; + BinaryData maxOutputTokens = default; IReadOnlyList output = default; + IReadOnlyList modalities = default; + ConversationVoice? voice = default; + ConversationAudioFormat? outputAudioFormat = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -171,6 +223,7 @@ internal static InternalRealtimeResponse DeserializeInternalRealtimeResponse(Jso { if (prop.Value.ValueKind == JsonValueKind.Null) { + metadata = new ChangeTrackingDictionary(); continue; } Dictionary dictionary = new Dictionary(); @@ -197,6 +250,29 @@ internal static InternalRealtimeResponse DeserializeInternalRealtimeResponse(Jso usage = ConversationTokenUsage.DeserializeConversationTokenUsage(prop.Value, options); continue; } + if (prop.NameEquals("conversation_id"u8)) + { + conversationId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("temperature"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + temperature = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("max_output_tokens"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxOutputTokens = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } if (prop.NameEquals("output"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) @@ -211,6 +287,38 @@ internal static InternalRealtimeResponse DeserializeInternalRealtimeResponse(Jso output = array; continue; } + if (prop.NameEquals("modalities"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new InternalRealtimeResponseModality(item.GetString())); + } + modalities = array; + continue; + } + if (prop.NameEquals("voice"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + voice = new ConversationVoice(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output_audio_format"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outputAudioFormat = new ConversationAudioFormat(prop.Value.GetString()); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); @@ -221,9 +329,15 @@ internal static InternalRealtimeResponse DeserializeInternalRealtimeResponse(Jso @object, status, statusDetails, - metadata ?? new ChangeTrackingDictionary(), + metadata, usage, + conversationId, + temperature, + maxOutputTokens, output ?? new ChangeTrackingList(), + modalities ?? new ChangeTrackingList(), + voice, + outputAudioFormat, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponse.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponse.cs index c087e6191..a2a824d41 100644 --- a/.dotnet/src/Generated/Models/InternalRealtimeResponse.cs +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponse.cs @@ -12,13 +12,14 @@ internal partial class InternalRealtimeResponse { private protected IDictionary _additionalBinaryDataProperties; - internal InternalRealtimeResponse() + internal InternalRealtimeResponse(IDictionary metadata) { - Metadata = new ChangeTrackingDictionary(); + Metadata = metadata; Output = new ChangeTrackingList(); + Modalities = new ChangeTrackingList(); } - internal InternalRealtimeResponse(string id, InternalRealtimeResponseObject? @object, ConversationStatus? status, ConversationStatusDetails statusDetails, IDictionary metadata, ConversationTokenUsage usage, IReadOnlyList output, IDictionary additionalBinaryDataProperties) + internal InternalRealtimeResponse(string id, InternalRealtimeResponseObject? @object, ConversationStatus? status, ConversationStatusDetails statusDetails, IDictionary metadata, ConversationTokenUsage usage, string conversationId, float? temperature, BinaryData maxOutputTokens, IReadOnlyList output, IReadOnlyList modalities, ConversationVoice? voice, ConversationAudioFormat? outputAudioFormat, IDictionary additionalBinaryDataProperties) { Id = id; Object = @object; @@ -26,7 +27,13 @@ internal InternalRealtimeResponse(string id, InternalRealtimeResponseObject? @ob StatusDetails = statusDetails; Metadata = metadata; Usage = usage; + ConversationId = conversationId; + Temperature = temperature; + MaxOutputTokens = maxOutputTokens; Output = output; + Modalities = modalities; + Voice = voice; + OutputAudioFormat = outputAudioFormat; _additionalBinaryDataProperties = additionalBinaryDataProperties; } @@ -42,6 +49,12 @@ internal InternalRealtimeResponse(string id, InternalRealtimeResponseObject? @ob public ConversationTokenUsage Usage { get; } + public string ConversationId { get; } + + public float? Temperature { get; } + + public BinaryData MaxOutputTokens { get; } + internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseModality.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseModality.cs new file mode 100644 index 000000000..363f5e034 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseModality.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + internal readonly partial struct InternalRealtimeResponseModality : IEquatable + { + private readonly string _value; + private const string TextValue = "text"; + private const string AudioValue = "audio"; + + public InternalRealtimeResponseModality(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalRealtimeResponseModality Text { get; } = new InternalRealtimeResponseModality(TextValue); + + public static InternalRealtimeResponseModality Audio { get; } = new InternalRealtimeResponseModality(AudioValue); + + public static bool operator ==(InternalRealtimeResponseModality left, InternalRealtimeResponseModality right) => left.Equals(right); + + public static bool operator !=(InternalRealtimeResponseModality left, InternalRealtimeResponseModality right) => !left.Equals(right); + + public static implicit operator InternalRealtimeResponseModality(string value) => new InternalRealtimeResponseModality(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRealtimeResponseModality other && Equals(other); + + public bool Equals(InternalRealtimeResponseModality other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseOutputAudioFormat.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseOutputAudioFormat.cs new file mode 100644 index 000000000..3eed3ffa9 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseOutputAudioFormat.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + internal readonly partial struct InternalRealtimeResponseOutputAudioFormat : IEquatable + { + private readonly string _value; + private const string Pcm16Value = "pcm16"; + private const string G711UlawValue = "g711_ulaw"; + private const string G711AlawValue = "g711_alaw"; + + public InternalRealtimeResponseOutputAudioFormat(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalRealtimeResponseOutputAudioFormat Pcm16 { get; } = new InternalRealtimeResponseOutputAudioFormat(Pcm16Value); + + public static InternalRealtimeResponseOutputAudioFormat G711Ulaw { get; } = new InternalRealtimeResponseOutputAudioFormat(G711UlawValue); + + public static InternalRealtimeResponseOutputAudioFormat G711Alaw { get; } = new InternalRealtimeResponseOutputAudioFormat(G711AlawValue); + + public static bool operator ==(InternalRealtimeResponseOutputAudioFormat left, InternalRealtimeResponseOutputAudioFormat right) => left.Equals(right); + + public static bool operator !=(InternalRealtimeResponseOutputAudioFormat left, InternalRealtimeResponseOutputAudioFormat right) => !left.Equals(right); + + public static implicit operator InternalRealtimeResponseOutputAudioFormat(string value) => new InternalRealtimeResponseOutputAudioFormat(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRealtimeResponseOutputAudioFormat other && Equals(other); + + public bool Equals(InternalRealtimeResponseOutputAudioFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalRealtimeResponseVoice.cs b/.dotnet/src/Generated/Models/InternalRealtimeResponseVoice.cs new file mode 100644 index 000000000..488f38252 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRealtimeResponseVoice.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.RealtimeConversation +{ + internal readonly partial struct InternalRealtimeResponseVoice : IEquatable + { + private readonly string _value; + private const string AlloyValue = "alloy"; + private const string AshValue = "ash"; + private const string BalladValue = "ballad"; + private const string CoralValue = "coral"; + private const string EchoValue = "echo"; + private const string SageValue = "sage"; + private const string ShimmerValue = "shimmer"; + private const string VerseValue = "verse"; + + public InternalRealtimeResponseVoice(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalRealtimeResponseVoice Alloy { get; } = new InternalRealtimeResponseVoice(AlloyValue); + + public static InternalRealtimeResponseVoice Ash { get; } = new InternalRealtimeResponseVoice(AshValue); + + public static InternalRealtimeResponseVoice Ballad { get; } = new InternalRealtimeResponseVoice(BalladValue); + + public static InternalRealtimeResponseVoice Coral { get; } = new InternalRealtimeResponseVoice(CoralValue); + + public static InternalRealtimeResponseVoice Echo { get; } = new InternalRealtimeResponseVoice(EchoValue); + + public static InternalRealtimeResponseVoice Sage { get; } = new InternalRealtimeResponseVoice(SageValue); + + public static InternalRealtimeResponseVoice Shimmer { get; } = new InternalRealtimeResponseVoice(ShimmerValue); + + public static InternalRealtimeResponseVoice Verse { get; } = new InternalRealtimeResponseVoice(VerseValue); + + public static bool operator ==(InternalRealtimeResponseVoice left, InternalRealtimeResponseVoice right) => left.Equals(right); + + public static bool operator !=(InternalRealtimeResponseVoice left, InternalRealtimeResponseVoice right) => !left.Equals(right); + + public static implicit operator InternalRealtimeResponseVoice(string value) => new InternalRealtimeResponseVoice(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRealtimeResponseVoice other && Equals(other); + + public bool Equals(InternalRealtimeResponseVoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/MessageCreationOptions.Serialization.cs b/.dotnet/src/Generated/Models/MessageCreationOptions.Serialization.cs index 171c2df2a..24e5ec428 100644 --- a/.dotnet/src/Generated/Models/MessageCreationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/MessageCreationOptions.Serialization.cs @@ -46,26 +46,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (_additionalBinaryDataProperties?.ContainsKey("role") != true) { diff --git a/.dotnet/src/Generated/Models/MessageCreationOptions.cs b/.dotnet/src/Generated/Models/MessageCreationOptions.cs index b1399e854..c8c4b234c 100644 --- a/.dotnet/src/Generated/Models/MessageCreationOptions.cs +++ b/.dotnet/src/Generated/Models/MessageCreationOptions.cs @@ -22,7 +22,7 @@ internal MessageCreationOptions(IList attachments, ID public IList Attachments { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/MessageModificationOptions.Serialization.cs b/.dotnet/src/Generated/Models/MessageModificationOptions.Serialization.cs index a80017c74..bcb1eebd4 100644 --- a/.dotnet/src/Generated/Models/MessageModificationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/MessageModificationOptions.Serialization.cs @@ -29,26 +29,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (true && _additionalBinaryDataProperties != null) { diff --git a/.dotnet/src/Generated/Models/MessageModificationOptions.cs b/.dotnet/src/Generated/Models/MessageModificationOptions.cs index 3818571f7..128b930b5 100644 --- a/.dotnet/src/Generated/Models/MessageModificationOptions.cs +++ b/.dotnet/src/Generated/Models/MessageModificationOptions.cs @@ -23,7 +23,7 @@ internal MessageModificationOptions(IDictionary metadata, IDicti _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/RunCreationOptions.Serialization.cs b/.dotnet/src/Generated/Models/RunCreationOptions.Serialization.cs index ee5dc6c45..e205dd689 100644 --- a/.dotnet/src/Generated/Models/RunCreationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/RunCreationOptions.Serialization.cs @@ -133,26 +133,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(Temperature) && _additionalBinaryDataProperties?.ContainsKey("temperature") != true) { diff --git a/.dotnet/src/Generated/Models/RunModificationOptions.Serialization.cs b/.dotnet/src/Generated/Models/RunModificationOptions.Serialization.cs index a5fbcc544..4a77d2e2b 100644 --- a/.dotnet/src/Generated/Models/RunModificationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/RunModificationOptions.Serialization.cs @@ -29,26 +29,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (true && _additionalBinaryDataProperties != null) { diff --git a/.dotnet/src/Generated/Models/RunModificationOptions.cs b/.dotnet/src/Generated/Models/RunModificationOptions.cs index 4295bfb3f..45750f93b 100644 --- a/.dotnet/src/Generated/Models/RunModificationOptions.cs +++ b/.dotnet/src/Generated/Models/RunModificationOptions.cs @@ -23,7 +23,7 @@ internal RunModificationOptions(IDictionary metadata, IDictionar _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/ThreadCreationOptions.Serialization.cs b/.dotnet/src/Generated/Models/ThreadCreationOptions.Serialization.cs index 8fd981fe1..ebe9da764 100644 --- a/.dotnet/src/Generated/Models/ThreadCreationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ThreadCreationOptions.Serialization.cs @@ -29,26 +29,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(ToolResources) && _additionalBinaryDataProperties?.ContainsKey("tool_resources") != true) { diff --git a/.dotnet/src/Generated/Models/ThreadCreationOptions.cs b/.dotnet/src/Generated/Models/ThreadCreationOptions.cs index 7675b5648..c667f5dff 100644 --- a/.dotnet/src/Generated/Models/ThreadCreationOptions.cs +++ b/.dotnet/src/Generated/Models/ThreadCreationOptions.cs @@ -26,7 +26,7 @@ internal ThreadCreationOptions(IDictionary metadata, ToolResourc _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/ThreadModificationOptions.Serialization.cs b/.dotnet/src/Generated/Models/ThreadModificationOptions.Serialization.cs index b1bad14a1..93c91dc45 100644 --- a/.dotnet/src/Generated/Models/ThreadModificationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ThreadModificationOptions.Serialization.cs @@ -29,26 +29,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(ToolResources) && _additionalBinaryDataProperties?.ContainsKey("tool_resources") != true) { diff --git a/.dotnet/src/Generated/Models/ThreadModificationOptions.cs b/.dotnet/src/Generated/Models/ThreadModificationOptions.cs index 261bcaf15..ee4e2f169 100644 --- a/.dotnet/src/Generated/Models/ThreadModificationOptions.cs +++ b/.dotnet/src/Generated/Models/ThreadModificationOptions.cs @@ -24,7 +24,7 @@ internal ThreadModificationOptions(IDictionary metadata, ToolRes _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs b/.dotnet/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs index 91403959b..e5147480d 100644 --- a/.dotnet/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs @@ -49,26 +49,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(ExpirationPolicy) && _additionalBinaryDataProperties?.ContainsKey("expires_after") != true) { diff --git a/.dotnet/src/Generated/Models/VectorStoreCreationOptions.cs b/.dotnet/src/Generated/Models/VectorStoreCreationOptions.cs index 563e1c7d3..0e0e42598 100644 --- a/.dotnet/src/Generated/Models/VectorStoreCreationOptions.cs +++ b/.dotnet/src/Generated/Models/VectorStoreCreationOptions.cs @@ -32,7 +32,7 @@ internal VectorStoreCreationOptions(IList fileIds, string name, IDiction public string Name { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/Models/VectorStoreModificationOptions.Serialization.cs b/.dotnet/src/Generated/Models/VectorStoreModificationOptions.Serialization.cs index ad9c7f889..f74cbb1cb 100644 --- a/.dotnet/src/Generated/Models/VectorStoreModificationOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/VectorStoreModificationOptions.Serialization.cs @@ -41,26 +41,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsCollectionDefined(Metadata) && _additionalBinaryDataProperties?.ContainsKey("metadata") != true) { - if (Metadata != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStringValue(item.Value); + writer.WriteNullValue(); + continue; } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"u8); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } if (Optional.IsDefined(ExpirationPolicy) && _additionalBinaryDataProperties?.ContainsKey("expires_after") != true) { diff --git a/.dotnet/src/Generated/Models/VectorStoreModificationOptions.cs b/.dotnet/src/Generated/Models/VectorStoreModificationOptions.cs index a9a6d29b1..9a581468d 100644 --- a/.dotnet/src/Generated/Models/VectorStoreModificationOptions.cs +++ b/.dotnet/src/Generated/Models/VectorStoreModificationOptions.cs @@ -27,7 +27,7 @@ internal VectorStoreModificationOptions(string name, IDictionary public string Name { get; set; } - public IDictionary Metadata { get; set; } + public IDictionary Metadata { get; } internal IDictionary SerializedAdditionalRawData { diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index 293b06fdf..eefd3e7d6 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -476,7 +476,7 @@ public static ConversationContentPart ConversationContentPart(string kind = defa return new UnknownRealtimeContentPart(new ConversationContentPartKind(kind), additionalBinaryDataProperties: null); } - public static ConversationResponseOptions ConversationResponseOptions(string instructions = default, ConversationVoice? voice = default, ConversationAudioFormat? outputAudioFormat = default, IEnumerable tools = default, float? temperature = default, IDictionary metadata = default, ResponseConversationSelection? conversationSelection = default, IEnumerable overrideItems = default, IEnumerable internalModalities = default, BinaryData internalToolChoice = default, BinaryData maxResponseOutputTokens = default) + public static ConversationResponseOptions ConversationResponseOptions(string instructions = default, ConversationVoice? voice = default, ConversationAudioFormat? outputAudioFormat = default, IEnumerable tools = default, float? temperature = default, IDictionary metadata = default, ResponseConversationSelection? conversationSelection = default, RealtimeConversation.ConversationMaxTokensChoice maxOutputTokens = default, IEnumerable overrideItems = default, IEnumerable internalModalities = default, BinaryData internalToolChoice = default) { tools ??= new ChangeTrackingList(); metadata ??= new ChangeTrackingDictionary(); @@ -491,10 +491,10 @@ public static ConversationResponseOptions ConversationResponseOptions(string ins temperature, metadata, conversationSelection, + maxOutputTokens, overrideItems?.ToList(), internalModalities?.ToList(), internalToolChoice, - maxResponseOutputTokens, additionalBinaryDataProperties: null); } diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index 730716937..18ceb4b8f 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -395,8 +395,14 @@ paths: type: object additionalProperties: type: string - nullable: true - description: Optional custom metadata for the batch. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. + x-oaiTypeLabel: map required: - input_file_id - endpoint @@ -3040,7 +3046,13 @@ components: additionalProperties: type: string nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map readOnly: true temperature: @@ -3691,6 +3703,7 @@ components: - completion_window - status - created_at + - metadata properties: id: type: string @@ -3815,7 +3828,13 @@ components: additionalProperties: type: string nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map BatchRequestInput: type: object @@ -3892,7 +3911,10 @@ components: type: string description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. parameters: - $ref: '#/components/schemas/FunctionParameters' + description: |- + The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + + Omitting `parameters` defines a function with an empty parameter list. deprecated: true ChatCompletionMessageAudioChunk: type: object @@ -4451,9 +4473,10 @@ components: format: float description: The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. bytes: - type: object - allOf: - - $ref: '#/components/schemas/ChatCompletionTokenLogprobBytesItem' + type: array + items: + type: integer + format: int32 nullable: true description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. top_logprobs: @@ -4480,11 +4503,6 @@ components: - logprob - bytes description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. - ChatCompletionTokenLogprobBytesItem: - type: array - items: - type: integer - format: int32 ChatCompletionTool: type: object required: @@ -4776,8 +4794,13 @@ components: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map temperature: type: number @@ -4880,6 +4903,8 @@ components: - type: string - type: string enum: + - o3-mini + - o3-mini-2025-01-31 - o1 - o1-2024-12-17 - o1-preview @@ -4946,10 +4971,14 @@ components: type: object additionalProperties: type: string - nullable: true description: |- - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. + x-oaiTypeLabel: map frequency_penalty: type: number format: float @@ -5121,8 +5150,8 @@ components: description: |- Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. + - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. - When not set, the default behavior is 'auto'. default: auto stop: @@ -5177,7 +5206,8 @@ components: tool_choice: $ref: '#/components/schemas/ChatCompletionToolChoiceOption' parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true user: type: string @@ -5894,9 +5924,9 @@ components: See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. integrations: - type: object - allOf: - - $ref: '#/components/schemas/CreateFineTuningJobRequestIntegrations' + type: array + items: + $ref: '#/components/schemas/CreateFineTuningJobRequestIntegration' nullable: true description: A list of integrations to enable for your fine-tuning job. seed: @@ -5933,10 +5963,6 @@ components: propertyName: type mapping: wandb: '#/components/schemas/CreateFineTuningJobRequestWandbIntegration' - CreateFineTuningJobRequestIntegrations: - type: array - items: - $ref: '#/components/schemas/CreateFineTuningJobRequestIntegration' CreateFineTuningJobRequestWandbIntegration: type: object required: @@ -6150,37 +6176,38 @@ components: $ref: '#/components/schemas/MessageContent' x-oaiExpandable: true attachments: - type: object - allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachmentsItem' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true + required: + - file_id + - tools nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map - CreateMessageRequestAttachmentsItem: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true - required: - - file_id - - tools CreateModerationRequest: type: object required: @@ -6585,23 +6612,29 @@ components: nullable: true description: Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions. additional_messages: - type: object - allOf: - - $ref: '#/components/schemas/CreateRunRequestAdditional_messages' + type: array + items: + $ref: '#/components/schemas/CreateMessageRequest' nullable: true description: Adds additional messages to the thread before creating the run. tools: - type: object - allOf: - - $ref: '#/components/schemas/CreateRunRequestTools' + type: array + items: + $ref: '#/components/schemas/AssistantToolDefinition' nullable: true description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + x-oaiExpandable: true metadata: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map temperature: type: number @@ -6648,22 +6681,13 @@ components: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' nullable: true parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true response_format: allOf: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' nullable: true - CreateRunRequestAdditional_messages: - type: array - items: - $ref: '#/components/schemas/CreateMessageRequest' - CreateRunRequestTools: - type: array - items: - $ref: '#/components/schemas/AssistantToolDefinition' - maxItems: 20 - x-oaiExpandable: true CreateSpeechRequest: type: object required: @@ -6762,9 +6786,9 @@ components: nullable: true description: Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis. tools: - type: object - allOf: - - $ref: '#/components/schemas/CreateThreadAndRunRequestTools' + type: array + items: + $ref: '#/components/schemas/AssistantToolDefinition' nullable: true description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. tool_resources: @@ -6788,8 +6812,13 @@ components: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map temperature: type: number @@ -6836,17 +6865,13 @@ components: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' nullable: true parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true response_format: allOf: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' nullable: true - CreateThreadAndRunRequestTools: - type: array - items: - $ref: '#/components/schemas/AssistantToolDefinition' - maxItems: 20 CreateThreadRequest: type: object properties: @@ -6876,8 +6901,13 @@ components: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map description: |- Options to create a new thread. If no thread is provided when running a @@ -6905,9 +6935,12 @@ components: additionalProperties: type: string description: |- - Set of 16 key-value pairs that can be attached to a vector store. This can be useful for - storing additional information about the vector store in a structured format. Keys can - be a maximum of 64 characters long and values can be a maxium of 512 characters long. + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map maxItems: 1 description: |- @@ -6944,7 +6977,7 @@ components: x-oaiTypeLabel: string language: type: string - description: The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. + description: The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency. prompt: type: string description: An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should match the audio language. @@ -7161,8 +7194,13 @@ components: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map DefaultProjectErrorResponse: type: object @@ -7397,7 +7435,8 @@ components: $ref: '#/components/schemas/ChatCompletionTool' description: A list of tools the model may generate JSON inputs for. parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true functions: type: array @@ -7499,7 +7538,8 @@ components: $ref: '#/components/schemas/ChatCompletionTool' description: A list of tools the model may generate JSON inputs for. parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true preferred_completion: type: array @@ -7738,11 +7778,12 @@ components: nullable: true description: The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents). integrations: - type: object - allOf: - - $ref: '#/components/schemas/FineTuningJobIntegrationsItem' + type: array + items: + $ref: '#/components/schemas/FineTuningIntegration' nullable: true description: A list of integrations to enable for this fine-tuning job. + x-oaiExpandable: true seed: type: integer format: int32 @@ -7866,12 +7907,6 @@ components: type: string enum: - auto - FineTuningJobIntegrationsItem: - type: array - items: - $ref: '#/components/schemas/FineTuningIntegration' - maxItems: 5 - x-oaiExpandable: true FunctionObject: type: object required: @@ -7884,15 +7919,23 @@ components: type: string description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. parameters: - $ref: '#/components/schemas/FunctionParameters' + description: |- + The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + + Omitting `parameters` defines a function with an empty parameter list. strict: type: boolean nullable: true description: Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling). default: false - FunctionParameters: + FunctionParametersCommon: type: object - additionalProperties: {} + properties: + parameters: + description: |- + The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + + Omitting `parameters` defines a function with an empty parameter list. description: |- The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. @@ -8909,9 +8952,21 @@ components: nullable: true description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachmentsItem' + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + type: array + items: + anyOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' + description: The tools to add this file to. + x-oaiExpandable: true nullable: true description: A list of files attached to the message, and the tools they were added to. metadata: @@ -8919,26 +8974,16 @@ components: additionalProperties: type: string nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map readOnly: true description: Represents a message within a [thread](/docs/api-reference/threads). - MessageObjectAttachmentsItem: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - type: array - items: - anyOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' - description: The tools to add this file to. - x-oaiExpandable: true MessageRequestContentTextObject: type: object required: @@ -8956,6 +9001,46 @@ components: allOf: - $ref: '#/components/schemas/MessageContent' description: The text content that is part of a message. + MetadataPropertyForRequest: + type: object + properties: + metadata: + type: object + additionalProperties: + type: string + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. + x-oaiTypeLabel: map + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. + MetadataPropertyForResponse: + type: object + required: + - metadata + properties: + metadata: + type: object + additionalProperties: + type: string + nullable: true + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. + x-oaiTypeLabel: map Model: type: object required: @@ -9037,8 +9122,13 @@ components: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map temperature: type: number @@ -9070,8 +9160,13 @@ components: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map ModifyRunRequest: type: object @@ -9080,8 +9175,13 @@ components: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map ModifyThreadRequest: type: object @@ -9107,8 +9207,13 @@ components: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map OmniTypedResponseFormat: type: object @@ -9190,6 +9295,9 @@ components: allOf: - $ref: '#/components/schemas/FileChunkingStrategyResponseParam' description: This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API. + ParallelToolCalls: + type: boolean + description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. PredictionContent: type: object required: @@ -10300,6 +10408,8 @@ components: - $ref: '#/components/schemas/RealtimeRequestMessageItem' RealtimeResponse: type: object + required: + - metadata properties: id: type: string @@ -10369,7 +10479,13 @@ components: additionalProperties: type: string nullable: true - description: Developer-provided string key-value pairs associated with this response. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map usage: type: object @@ -10425,6 +10541,63 @@ components: Realtime API session will maintain a conversation context and append new Items to the Conversation, thus output from previous turns (text and audio tokens) will become the input for later turns. + conversation_id: + type: string + description: |- + Which conversation the response is added to, determined by the `conversation` + field in the `response.create` event. If `auto`, the response will be added to + the default conversation and the value of `conversation_id` will be an id like + `conv_1234`. If `none`, the response will not be added to any conversation and + the value of `conversation_id` will be `null`. If responses are being triggered + by server VAD, the response will be added to the default conversation, thus + the `conversation_id` will be an id like `conv_1234`. + voice: + type: string + enum: + - alloy + - ash + - ballad + - coral + - echo + - sage + - shimmer + - verse + description: |- + The voice the model used to respond. + Current voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + `shimmer` and `verse`. + modalities: + type: array + items: + type: string + enum: + - text + - audio + description: |- + The set of modalities the model used to respond. If there are multiple modalities, + the model will pick one, for example if `modalities` is `["text", "audio"]`, the model + could be responding in either text or audio. + output_audio_format: + type: string + enum: + - pcm16 + - g711_ulaw + - g711_alaw + description: The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + temperature: + type: number + format: float + description: Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. + max_output_tokens: + anyOf: + - type: integer + format: int32 + - type: string + enum: + - inf + description: |- + Maximum number of output tokens for a single assistant response, + inclusive of tool calls, that was used in this response. description: The response resource. RealtimeResponseAudioContentPart: type: object @@ -10492,7 +10665,7 @@ components: type: number format: float description: Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. - max_response_output_tokens: + max_output_tokens: anyOf: - type: integer format: int32 @@ -10521,12 +10694,13 @@ components: type: object additionalProperties: type: string - nullable: true description: |- Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured - format. Keys can be a maximum of 64 characters long and values can be a - maximum of 512 characters long. + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map input: type: array @@ -11714,12 +11888,19 @@ components: description: |- The model to use for transcription, `whisper-1` is the only currently supported model. - description: |- - Configuration for input audio transcription, defaults to off and can be - set to `null` to turn off once on. Input audio transcription is not native - to the model, since the model consumes audio directly. Transcription runs - asynchronously through Whisper and should be treated as rough guidance - rather than the representation understood by the model. + language: + type: string + description: |- + The language of the input audio. Supplying the input language in + [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format + will improve accuracy and latency. + prompt: + type: string + description: |- + An optional text to guide the model's style or continue a previous audio + segment. The [prompt](/docs/guides/speech-to-text#prompting) should match + the audio language. + description: Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as rough guidance rather than the representation understood by the model. The client can optionally set the language and prompt for transcription, these fields will be passed to the Whisper API. turn_detection: type: object properties: @@ -11785,6 +11966,8 @@ components: description: Realtime session object configuration. RealtimeSessionCreateResponse: type: object + required: + - client_secret properties: client_secret: type: object @@ -11801,6 +11984,9 @@ components: description: |- Timestamp for when the token expires. Currently, all tokens expire after one minute. + required: + - value + - expires_at description: Ephemeral key returned by the API. modalities: type: array @@ -12250,7 +12436,13 @@ components: additionalProperties: type: string nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map readOnly: true usage: @@ -12290,7 +12482,8 @@ components: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' nullable: true parallel_tool_calls: - type: boolean + allOf: + - $ref: '#/components/schemas/ParallelToolCalls' default: true response_format: allOf: @@ -12940,7 +13133,13 @@ components: additionalProperties: type: string nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map readOnly: true usage: @@ -13112,7 +13311,13 @@ components: additionalProperties: type: string nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map readOnly: true description: Represents a thread that contains [messages](/docs/api-reference/messages). @@ -13151,9 +13356,12 @@ components: additionalProperties: type: string description: |- - Set of 16 key-value pairs that can be attached to a vector store. This can be useful for - storing additional information about the vector store in a structured format. Keys can - be a maximum of 64 characters long and values can be a maxium of 512 characters long. + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map maxItems: 1 description: |- @@ -13198,9 +13406,12 @@ components: additionalProperties: type: string description: |- - Set of 16 key-value pairs that can be attached to a vector store. This can be useful for - storing additional information about the vector store in a structured format. Keys can - be a maximum of 64 characters long and values can be a maxium of 512 characters long. + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map maxItems: 1 description: |- @@ -13318,8 +13529,13 @@ components: type: object additionalProperties: type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map Upload: type: object @@ -14043,7 +14259,13 @@ components: additionalProperties: type: string nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + description: |- + Set of 16 key-value pairs that can be attached to an object. This can be + useful for storing additional information about the object in a structured + format, and querying for objects via API or the dashboard. + + Keys are strings with a maximum length of 64 characters. Values are strings + with a maximum length of 512 characters. x-oaiTypeLabel: map readOnly: true description: A vector store is a collection of processed files can be used by the `file_search` tool. diff --git a/.typespec/administration/models.tsp b/.typespec/administration/models.tsp index e9c6c9061..2e76978a5 100644 --- a/.typespec/administration/models.tsp +++ b/.typespec/administration/models.tsp @@ -7,6 +7,24 @@ using TypeSpec.OpenAPI; namespace OpenAI; +// Tool generated type. Extracts from Invite.projects +alias InviteProject = { + /** Project's public ID */ + id?: string; + + /** Project membership role */ + role?: "member" | "owner"; +}; + +// Tool generated type. Extracts from InviteRequest.projects +alias InviteRequestProject = { + /** Project's public ID */ + id: string; + + /** Project membership role */ + role: "member" | "owner"; +}; + /** The service account that performed the audit logged action. */ model AuditLogActorServiceAccount { /** The service account id. */ @@ -460,13 +478,7 @@ model Invite { accepted_at?: utcDateTime; /** The projects that were granted membership upon acceptance of the invite. */ - projects?: { - /** Project's public ID */ - id?: string; - - /** Project membership role */ - role?: "member" | "owner"; - }[]; + projects?: InviteProject[]; } model InviteListResponse { @@ -503,13 +515,7 @@ model InviteRequest { role: "reader" | "owner"; /** An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. */ - projects?: { - /** Project's public ID */ - id: string; - - /** Project membership role */ - role: "member" | "owner"; - }[]; + projects?: InviteRequestProject[]; } model InviteDeleteResponse { diff --git a/.typespec/assistants/custom.tsp b/.typespec/assistants/custom.tsp index e557bac28..e93f9710b 100644 --- a/.typespec/assistants/custom.tsp +++ b/.typespec/assistants/custom.tsp @@ -50,13 +50,7 @@ alias ToolResourcesFileSearchVectorStoreCreationHelper = { @extension("x-oaiExpandable", true) chunking_strategy?: AutoChunkingStrategyRequestParam | StaticChunkingStrategyRequestParam; - /** - * Set of 16 key-value pairs that can be attached to a vector store. This can be useful for - * storing additional information about the vector store in a structured format. Keys can - * be a maximum of 64 characters long and values can be a maxium of 512 characters long. - */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record; + ...MetadataPropertyForRequest; }; @discriminator("type") diff --git a/.typespec/assistants/models.tsp b/.typespec/assistants/models.tsp index d2cf1554d..299e9262b 100644 --- a/.typespec/assistants/models.tsp +++ b/.typespec/assistants/models.tsp @@ -93,10 +93,7 @@ model CreateAssistantRequest { file_search?: ToolResourcesFileSearch; } | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; /** What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. */ @minValue(0) @@ -155,10 +152,7 @@ model ModifyAssistantRequest { file_search?: ToolResourcesFileSearchIdsOnly; } | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; /** What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. */ @minValue(0) @@ -313,10 +307,7 @@ model AssistantObject { file_search?: ToolResourcesFileSearchIdsOnly; } | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata: Record | null; + ...MetadataPropertyForResponse; /** What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. */ @minValue(0) diff --git a/.typespec/audio/models.tsp b/.typespec/audio/models.tsp index 83f843391..a2f95ddce 100644 --- a/.typespec/audio/models.tsp +++ b/.typespec/audio/models.tsp @@ -69,7 +69,9 @@ model CreateTranscriptionRequest { @extension("x-oaiTypeLabel", "string") `model`: string | "whisper-1"; - /** The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. */ + @doc(""" + The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency. + """) language?: string; /** An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text#prompting) should match the audio language. */ diff --git a/.typespec/batch/models.tsp b/.typespec/batch/models.tsp index 7e6aaf2eb..ede020428 100644 --- a/.typespec/batch/models.tsp +++ b/.typespec/batch/models.tsp @@ -3,10 +3,27 @@ * Edits made directly to this file will be lost. */ +import "../common"; + using TypeSpec.OpenAPI; namespace OpenAI; +// Tool generated type. Extracts from Batch.errors.data +alias BatchErrorsData = { + /** An error code identifying the error type. */ + code?: string; + + /** A human-readable message providing more details about the error. */ + message?: string; + + /** The name of the parameter that caused the error, if applicable. */ + param?: string | null; + + /** The line number of the input file where the error occurred, if applicable. */ + line?: int32 | null; +}; + model Batch { id: string; @@ -25,19 +42,7 @@ model Batch { """) object?: "list"; - data?: { - /** An error code identifying the error type. */ - code?: string; - - /** A human-readable message providing more details about the error. */ - message?: string; - - /** The name of the parameter that caused the error, if applicable. */ - param?: string | null; - - /** The line number of the input file where the error occurred, if applicable. */ - line?: int32 | null; - }[]; + data?: BatchErrorsData[]; }; /** The ID of the input file for the batch. */ @@ -120,10 +125,7 @@ model Batch { failed: int32; }; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForResponse; } /** The per-line object of the batch input file */ diff --git a/.typespec/batch/operations.tsp b/.typespec/batch/operations.tsp index efc9de291..dfc7508da 100644 --- a/.typespec/batch/operations.tsp +++ b/.typespec/batch/operations.tsp @@ -40,7 +40,7 @@ interface Batches { completion_window: "24h", /** Optional custom metadata for the batch. */ - metadata?: Record | null, + ...MetadataPropertyForRequest, ): Batch | ErrorResponse; @get diff --git a/.typespec/chat/models.tsp b/.typespec/chat/models.tsp index d28f4413a..7354fb0b9 100644 --- a/.typespec/chat/models.tsp +++ b/.typespec/chat/models.tsp @@ -10,8 +10,103 @@ using TypeSpec.OpenAPI; namespace OpenAI; -// Tool generated type. Extracts ChatCompletionTokenLogprob.bytes -model ChatCompletionTokenLogprobBytes is int32[]; +// Tool generated type. Extracts from CreateChatCompletionResponse.choices +alias CreateChatCompletionResponseChoice = { + @doc(""" + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + """) + finish_reason: + | "stop" + | "length" + | "tool_calls" + | "content_filter" + | "function_call"; + + /** The index of the choice in the list of choices. */ + index: int32; + + message: ChatCompletionResponseMessage; + + /** Log probability information for the choice. */ + logprobs: { + // Tool customization: Apply read-only visibility via annotation + /** A list of message content tokens with log probability information. */ + @visibility("read") + content: ChatCompletionTokenLogprob[] | null; + + // Tool customization: Apply read-only visibility via annotation + /** A list of message refusal tokens with log probability information. */ + @visibility("read") + refusal: ChatCompletionTokenLogprob[] | null; + } | null; +}; + +// Tool generated type. Extracts from CreateChatCompletionFunctionResponse.choices +alias CreateChatCompletionFunctionResponseChoice = { + @doc(""" + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function. + """) + finish_reason: "stop" | "length" | "function_call" | "content_filter"; + + /** The index of the choice in the list of choices. */ + index: int32; + + message: ChatCompletionResponseMessage; +}; + +// Tool generated type. Extracts from ChatCompletionTokenLogprob.top_logprobs +alias ChatCompletionTokenLogprobTopLogprob = { + /** The token. */ + token: string; + + @doc(""" + The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. + """) + logprob: float32; + + @doc(""" + A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. + """) + bytes: int32[] | null; +}; + +// Tool generated type. Extracts from CreateChatCompletionStreamResponse.choices +alias CreateChatCompletionStreamResponseChoice = { + delta: ChatCompletionStreamResponseDelta; + + /** Log probability information for the choice. */ + logprobs?: { + // Tool customization: Apply read-only visibility via annotation + /** A list of message content tokens with log probability information. */ + @visibility("read") + content: ChatCompletionTokenLogprob[] | null; + + // Tool customization: Apply read-only visibility via annotation + /** A list of message refusal tokens with log probability information. */ + @visibility("read") + refusal: ChatCompletionTokenLogprob[] | null; + } | null; + + @doc(""" + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + `content_filter` if content was omitted due to a flag from our content filters, + `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + """) + finish_reason: + | "stop" + | "length" + | "tool_calls" + | "content_filter" + | "function_call" + | null; + + /** The index of the choice in the list of choices. */ + index: int32; +}; model CreateChatCompletionRequest { /** @@ -27,6 +122,8 @@ model CreateChatCompletionRequest { @extension("x-oaiTypeLabel", "string") `model`: | string + | "o3-mini" + | "o3-mini-2025-01-31" | "o1" | "o1-2024-12-17" | "o1-preview" @@ -83,11 +180,7 @@ model CreateChatCompletionRequest { """) reasoning_effort?: "low" | "medium" | "high" = "medium"; - /** - * Developer-defined tags and values used for filtering completions - * in the [dashboard](https://platform.openai.com/chat-completions). - */ - metadata?: Record | null; + ...MetadataPropertyForRequest; /** * Number between -2.0 and 2.0. Positive values penalize new tokens based on @@ -227,8 +320,8 @@ model CreateChatCompletionRequest { /** * Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: * - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - * - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - * - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + * - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. + * - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. * - When not set, the default behavior is 'auto'. */ service_tier?: "auto" | "default" | null = "auto"; @@ -309,40 +402,10 @@ model CreateChatCompletionResponse { /** A unique identifier for the chat completion. */ id: string; - // Tool customization: Apply read-only visibility to inner logprobs types @doc(""" A list of chat completion choices. Can be more than one if `n` is greater than 1. """) - choices: { - @doc(""" - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - """) - finish_reason: - | "stop" - | "length" - | "tool_calls" - | "content_filter" - | "function_call"; - - /** The index of the choice in the list of choices. */ - index: int32; - - message: ChatCompletionResponseMessage; - - /** Log probability information for the choice. */ - logprobs: { - /** A list of message content tokens with log probability information. */ - @visibility("read") - content: ChatCompletionTokenLogprob[] | null; - - /** A list of message refusal tokens with log probability information. */ - @visibility("read") - refusal: ChatCompletionTokenLogprob[] | null; - } | null; - }[]; + choices: CreateChatCompletionResponseChoice[]; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime /** The Unix timestamp (in seconds) of when the chat completion was created. */ @@ -675,17 +738,7 @@ model CreateChatCompletionFunctionResponse { @doc(""" A list of chat completion choices. Can be more than one if `n` is greater than 1. """) - choices: { - @doc(""" - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function. - """) - finish_reason: "stop" | "length" | "function_call" | "content_filter"; - - /** The index of the choice in the list of choices. */ - index: int32; - - message: ChatCompletionResponseMessage; - }[]; + choices: CreateChatCompletionFunctionResponseChoice[]; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime /** The Unix timestamp (in seconds) of when the chat completion was created. */ @@ -776,25 +829,12 @@ model ChatCompletionTokenLogprob { @doc(""" A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. """) - bytes: ChatCompletionTokenLogprobBytes | null; + bytes: int32[] | null; @doc(""" List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. """) - top_logprobs: { - /** The token. */ - token: string; - - @doc(""" - The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. - """) - logprob: float32; - - @doc(""" - A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - """) - bytes: int32[] | null; - }[]; + top_logprobs: ChatCompletionTokenLogprobTopLogprob[]; } @doc(""" @@ -813,7 +853,7 @@ model ChatCompletionFunctions { /** The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ name: string; - parameters?: FunctionParameters; + ...FunctionParametersCommon; } // Tool customization: Add a missing "audio" to the chat streaming delta definition @@ -869,42 +909,11 @@ model CreateChatCompletionStreamResponse { /** A unique identifier for the chat completion. Each chunk has the same ID. */ id: string; - // Tool customization: Apply read-only visibility to inner logprobs types @doc(""" A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the last chunk if you set `stream_options: {"include_usage": true}`. """) - choices: { - delta: ChatCompletionStreamResponseDelta; - - /** Log probability information for the choice. */ - logprobs?: { - /** A list of message content tokens with log probability information. */ - @visibility("read") - content: ChatCompletionTokenLogprob[] | null; - - /** A list of message refusal tokens with log probability information. */ - @visibility("read") - refusal: ChatCompletionTokenLogprob[] | null; - } | null; - - @doc(""" - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - """) - finish_reason: - | "stop" - | "length" - | "tool_calls" - | "content_filter" - | "function_call" - | null; - - /** The index of the choice in the list of choices. */ - index: int32; - }[]; + choices: CreateChatCompletionStreamResponseChoice[]; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime /** The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp. */ diff --git a/.typespec/common/models.tsp b/.typespec/common/models.tsp index 9ad1b630e..d1b8d2802 100644 --- a/.typespec/common/models.tsp +++ b/.typespec/common/models.tsp @@ -22,12 +22,20 @@ model ErrorResponse { error: Error; } +// Tool customization: Wrap for reuse @doc(""" The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. Omitting `parameters` defines a function with an empty parameter list. """) -model FunctionParameters is Record; +model FunctionParametersCommon { + /** + * The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + * + * Omitting `parameters` defines a function with an empty parameter list. + */ + parameters?: unknown; +} model FunctionObject { /** A description of what the function does, used by the model to choose when and how to call the function. */ @@ -36,7 +44,7 @@ model FunctionObject { /** The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ name: string; - parameters?: FunctionParameters; + ...FunctionParametersCommon; @doc(""" Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling). @@ -44,6 +52,40 @@ model FunctionObject { strict?: boolean | null = false; } +// Tool customization: Wrap for reuse +/** + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format, and querying for objects via API or the dashboard. + * + * Keys are strings with a maximum length of 64 characters. Values are strings + * with a maximum length of 512 characters. + */ +model MetadataPropertyForRequest { + /** + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format, and querying for objects via API or the dashboard. + * + * Keys are strings with a maximum length of 64 characters. Values are strings + * with a maximum length of 512 characters. + */ + @extension("x-oaiTypeLabel", "map") + metadata?: Record; +} +model MetadataPropertyForResponse { + /** + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format, and querying for objects via API or the dashboard. + * + * Keys are strings with a maximum length of 64 characters. Values are strings + * with a maximum length of 512 characters. + */ + @extension("x-oaiTypeLabel", "map") + metadata: Record | null; +} + // Tool customization: establish a common, discriminated union model ResponseFormatText extends OmniTypedResponseFormat { @doc(""" @@ -87,7 +129,7 @@ model ResponseFormatJsonSchema extends OmniTypedResponseFormat { } /** Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. */ -alias ParallelToolCalls = boolean; +scalar ParallelToolCalls extends boolean; /** Usage statistics for the completion request. */ model CompletionUsage { diff --git a/.typespec/completions/models.tsp b/.typespec/completions/models.tsp index 4ac388561..4b8822bd2 100644 --- a/.typespec/completions/models.tsp +++ b/.typespec/completions/models.tsp @@ -9,6 +9,25 @@ using TypeSpec.OpenAPI; namespace OpenAI; +// Tool generated type. Extracts from CreateCompletionResponse.choices +alias CreateCompletionResponseChoice = { + @doc(""" + The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + `length` if the maximum number of tokens specified in the request was reached, + or `content_filter` if content was omitted due to a flag from our content filters. + """) + finish_reason: "stop" | "length" | "content_filter"; + + index: int32; + logprobs: { + text_offset?: int32[]; + token_logprobs?: float32[]; + tokens?: string[]; + top_logprobs?: Record[]; + } | null; + text: string; +}; + model CreateCompletionRequest { /** ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them. */ @extension("x-oaiTypeLabel", "string") @@ -141,23 +160,7 @@ model CreateCompletionResponse { id: string; /** The list of completion choices the model generated for the input prompt. */ - choices: { - @doc(""" - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - or `content_filter` if content was omitted due to a flag from our content filters. - """) - finish_reason: "stop" | "length" | "content_filter"; - - index: int32; - logprobs: { - text_offset?: int32[]; - token_logprobs?: float32[]; - tokens?: string[]; - top_logprobs?: Record[]; - } | null; - text: string; - }[]; + choices: CreateCompletionResponseChoice[]; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime /** The Unix timestamp (in seconds) of when the completion was created. */ diff --git a/.typespec/fine-tuning/models.tsp b/.typespec/fine-tuning/models.tsp index d162e6526..62f511e16 100644 --- a/.typespec/fine-tuning/models.tsp +++ b/.typespec/fine-tuning/models.tsp @@ -11,15 +11,6 @@ using TypeSpec.OpenAPI; namespace OpenAI; -// Tool generated type. Extracts CreateFineTuningJobRequest.integrations -model CreateFineTuningJobRequestIntegrations - is CreateFineTuningJobRequestIntegration[]; - -// Tool generated type. Extracts FineTuningJob.integrations -@maxItems(5) -@extension("x-oaiExpandable", true) -model FineTuningJobIntegrations is FineTuningIntegration[]; - model CreateFineTuningJobRequest { /** * The name of the model to fine-tune. You can select one of the @@ -96,7 +87,7 @@ model CreateFineTuningJobRequest { // Tool customization: establish a discriminated type basis /** A list of integrations to enable for your fine-tuning job. */ - integrations?: CreateFineTuningJobRequestIntegrations | null; + integrations?: CreateFineTuningJobRequestIntegration[] | null; /** * The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. @@ -226,7 +217,9 @@ model FineTuningJob { validation_file: string | null; /** A list of integrations to enable for this fine-tuning job. */ - integrations?: FineTuningJobIntegrations | null; + // !no_nullable! @maxItems(5) + @extension("x-oaiExpandable", true) + integrations?: FineTuningIntegration[] | null; /** The seed used for the fine-tuning job. */ seed: int32; diff --git a/.typespec/messages/models.tsp b/.typespec/messages/models.tsp index c4c40d32f..0766d0fdc 100644 --- a/.typespec/messages/models.tsp +++ b/.typespec/messages/models.tsp @@ -4,33 +4,32 @@ */ import "../assistants"; +import "../common"; import "./custom.tsp"; using TypeSpec.OpenAPI; namespace OpenAI; -// Tool generated type. Extracts CreateMessageRequest.attachments -model CreateMessageRequestAttachments - is { - /** The ID of the file to attach to the message. */ - file_id: string; +// Tool generated type. Extracts from CreateMessageRequest.attachments +alias CreateMessageRequestAttachment = { + /** The ID of the file to attach to the message. */ + file_id: string; - /** The tools to add this file to. */ - @extension("x-oaiExpandable", true) - tools: (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; - }[]; + /** The tools to add this file to. */ + @extension("x-oaiExpandable", true) + tools: (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; +}; -// Tool generated type. Extracts MessageObject.attachments -model MessageObjectAttachments - is { - /** The ID of the file to attach to the message. */ - file_id?: string; +// Tool generated type. Extracts from MessageObject.attachments +alias MessageObjectAttachment = { + /** The ID of the file to attach to the message. */ + file_id?: string; - /** The tools to add this file to. */ - @extension("x-oaiExpandable", true) - tools?: (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; - }[]; + /** The tools to add this file to. */ + @extension("x-oaiExpandable", true) + tools?: (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; +}; model CreateMessageRequest { @doc(""" @@ -45,19 +44,13 @@ model CreateMessageRequest { content: MessageContent[]; /** A list of files attached to the message, and the tools they should be added to. */ - attachments?: CreateMessageRequestAttachments | null; + attachments?: CreateMessageRequestAttachment[] | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; } model ModifyMessageRequest { - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; } model ListMessagesResponse { @@ -139,12 +132,9 @@ model MessageObject { run_id: string | null; /** A list of files attached to the message, and the tools they were added to. */ - attachments: MessageObjectAttachments | null; + attachments: MessageObjectAttachment[] | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata: Record | null; + ...MetadataPropertyForResponse; } // Tool customization: apply a common model base for all assistants message content items diff --git a/.typespec/realtime/models.tsp b/.typespec/realtime/models.tsp index f2d9c742e..7f03fdea8 100644 --- a/.typespec/realtime/models.tsp +++ b/.typespec/realtime/models.tsp @@ -3,6 +3,7 @@ * Edits made directly to this file will be lost. */ +import "../common"; import "./custom.tsp"; using TypeSpec.OpenAPI; @@ -91,10 +92,7 @@ model RealtimeResponse { /** The list of output items generated by the response. */ output?: RealtimeConversationResponseItem[]; - // Tool customization: specialize known metadata string maps - /** Developer-provided string key-value pairs associated with this response. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForResponse; /** * Usage statistics for the Response, this will correspond to billing. A @@ -142,6 +140,53 @@ model RealtimeResponse { audio_tokens?: int32; }; }; + + @doc(""" + Which conversation the response is added to, determined by the `conversation` + field in the `response.create` event. If `auto`, the response will be added to + the default conversation and the value of `conversation_id` will be an id like + `conv_1234`. If `none`, the response will not be added to any conversation and + the value of `conversation_id` will be `null`. If responses are being triggered + by server VAD, the response will be added to the default conversation, thus + the `conversation_id` will be an id like `conv_1234`. + """) + conversation_id?: string; + + @doc(""" + The voice the model used to respond. + Current voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, + `shimmer` and `verse`. + """) + voice?: + | "alloy" + | "ash" + | "ballad" + | "coral" + | "echo" + | "sage" + | "shimmer" + | "verse"; + + @doc(""" + The set of modalities the model used to respond. If there are multiple modalities, + the model will pick one, for example if `modalities` is `["text", "audio"]`, the model + could be responding in either text or audio. + """) + modalities?: ("text" | "audio")[]; + + @doc(""" + The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + """) + output_audio_format?: "pcm16" | "g711_ulaw" | "g711_alaw"; + + /** Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. */ + temperature?: float32; + + /** + * Maximum number of output tokens for a single assistant response, + * inclusive of tool calls, that was used in this response. + */ + max_output_tokens?: int32 | "inf"; } // Tool customization: apply discriminated type base @@ -1083,13 +1128,14 @@ model RealtimeResponseCreateParams { /** Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8. */ temperature?: float32; + // Tool customization: Address (observed as of 2025-01-31) spec issue with 'max_response_output_tokens' @doc(""" Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or `inf` for the maximum available tokens for a given model. Defaults to `inf`. """) - max_response_output_tokens?: int32 | "inf"; + max_output_tokens?: int32 | "inf"; @doc(""" Controls which conversation the response is added to. Currently supports @@ -1100,15 +1146,7 @@ model RealtimeResponseCreateParams { """) conversation?: string | "auto" | "none"; - // Tool customization: specialize known metadata string maps - /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. - */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; // Tool customization: apply a customized, specific item type /** @@ -1177,11 +1215,7 @@ model RealtimeSessionCreateRequest { output_audio_format?: RealtimeAudioFormat; @doc(""" - Configuration for input audio transcription, defaults to off and can be - set to `null` to turn off once on. Input audio transcription is not native - to the model, since the model consumes audio directly. Transcription runs - asynchronously through Whisper and should be treated as rough guidance - rather than the representation understood by the model. + Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as rough guidance rather than the representation understood by the model. The client can optionally set the language and prompt for transcription, these fields will be passed to the Whisper API. """) input_audio_transcription?: { @doc(""" @@ -1189,6 +1223,20 @@ model RealtimeSessionCreateRequest { supported model. """) `model`?: string; + + @doc(""" + The language of the input audio. Supplying the input language in + [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format + will improve accuracy and latency. + """) + language?: string; + + /** + * An optional text to guide the model's style or continue a previous audio + * segment. The [prompt](/docs/guides/speech-to-text#prompting) should match + * the audio language. + */ + prompt?: string; }; @doc(""" @@ -1257,13 +1305,13 @@ model RealtimeSessionCreateRequest { */ model RealtimeSessionCreateResponse { /** Ephemeral key returned by the API. */ - client_secret?: { + client_secret: { /** * Ephemeral key usable in client environments to authenticate connections * to the Realtime API. Use this in client-side environments rather than * a standard API token, which should only be used server-side. */ - value?: string; + value: string; // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime /** @@ -1271,7 +1319,7 @@ model RealtimeSessionCreateResponse { * after one minute. */ @encode("unixTimestamp", int32) - expires_at?: utcDateTime; + expires_at: utcDateTime; }; // Tool customization: Apply reusable modality representation diff --git a/.typespec/runs/models.tsp b/.typespec/runs/models.tsp index 4e23d851c..86f9d5e24 100644 --- a/.typespec/runs/models.tsp +++ b/.typespec/runs/models.tsp @@ -13,17 +13,25 @@ using TypeSpec.OpenAPI; namespace OpenAI; -// Tool generated type. Extracts CreateRunRequest.additional_messages -model CreateRunRequestAdditional_messages is CreateMessageRequest[]; +// Tool generated type. Extracts from SubmitToolOutputsRunRequest.tool_outputs +alias SubmitToolOutputsRunRequestToolOutput = { + @doc(""" + The ID of the tool call in the `required_action` object within the run object the output is being submitted for. + """) + tool_call_id?: string; -// Tool generated type. Extracts CreateRunRequest.tools -@maxItems(20) -@extension("x-oaiExpandable", true) -model CreateRunRequestTools is AssistantToolDefinition[]; + /** The output of the tool call to be submitted to continue the run. */ + output?: string; +}; -// Tool generated type. Extracts CreateThreadAndRunRequest.tools -@maxItems(20) -model CreateThreadAndRunRequestTools is AssistantToolDefinition[]; +// Tool generated type. Extracts from RunStepDetailsToolCallsFileSearchResultObject.content +alias RunStepDetailsToolCallsFileSearchResultObjectContent = { + /** The type of the content. */ + type?: "text"; + + /** The text content of the file. */ + text?: string; +}; model CreateRunRequest { /** The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. */ @@ -66,16 +74,15 @@ model CreateRunRequest { additional_instructions?: string | null; /** Adds additional messages to the thread before creating the run. */ - additional_messages?: CreateRunRequestAdditional_messages | null; + additional_messages?: CreateMessageRequest[] | null; // Tool customization: use common model base for tool definitions /** Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ - tools?: CreateRunRequestTools | null; + // !no_nullable! @maxItems(20) + @extension("x-oaiExpandable", true) + tools?: AssistantToolDefinition[] | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; /** What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. */ @minValue(0) @@ -115,10 +122,7 @@ model CreateRunRequest { } model ModifyRunRequest { - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; } model CreateThreadAndRunRequest { @@ -162,7 +166,8 @@ model CreateThreadAndRunRequest { // Tool customization: use common model base for tool definitions /** Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ - tools?: CreateThreadAndRunRequestTools | null; + // !no_nullable! @maxItems(20) + tools?: AssistantToolDefinition[] | null; @doc(""" A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. @@ -180,10 +185,7 @@ model CreateThreadAndRunRequest { file_search?: ToolResourcesFileSearchIdsOnly; } | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; /** What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. */ @minValue(0) @@ -224,15 +226,7 @@ model CreateThreadAndRunRequest { model SubmitToolOutputsRunRequest { /** A list of tools for which the outputs are being submitted. */ - tool_outputs: { - @doc(""" - The ID of the tool call in the `required_action` object within the run object the output is being submitted for. - """) - tool_call_id?: string; - - /** The output of the tool call to be submitted to continue the run. */ - output?: string; - }[]; + tool_outputs: SubmitToolOutputsRunRequestToolOutput[]; @doc(""" If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. @@ -393,13 +387,7 @@ model RunStepDetailsToolCallsFileSearchResultObject { score: float32; /** The content of the result that was found. The content is only included if requested via the include query parameter. */ - content?: { - /** The type of the content. */ - type?: "text"; - - /** The text content of the file. */ - text?: string; - }[]; + content?: RunStepDetailsToolCallsFileSearchResultObjectContent[]; } // Tool customization: apply custom, common base type to union items @@ -567,11 +555,7 @@ model RunObject { @extension("x-oaiExpandable", true) tools: AssistantToolDefinition[] = #[]; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata: Record | null; - + ...MetadataPropertyForResponse; usage: RunCompletionUsage | null; /** The sampling temperature used for this run. If not set, defaults to 1. */ @@ -666,11 +650,7 @@ model RunStepObject { @encode("unixTimestamp", int32) completed_at: utcDateTime | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata: Record | null; - + ...MetadataPropertyForResponse; usage: RunStepCompletionUsage | null; } diff --git a/.typespec/threads/custom.tsp b/.typespec/threads/custom.tsp index 256b16f67..1862f827e 100644 --- a/.typespec/threads/custom.tsp +++ b/.typespec/threads/custom.tsp @@ -42,11 +42,5 @@ alias CreateThreadRequestToolResourcesFileSearchVectorStoreCreationHelper = { @maxItems(10000) file_ids?: string[]; - /** - * Set of 16 key-value pairs that can be attached to a vector store. This can be useful for - * storing additional information about the vector store in a structured format. Keys can - * be a maximum of 64 characters long and values can be a maxium of 512 characters long. - */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record; + ...MetadataPropertyForRequest; }; diff --git a/.typespec/threads/models.tsp b/.typespec/threads/models.tsp index 8be177906..97d793921 100644 --- a/.typespec/threads/models.tsp +++ b/.typespec/threads/models.tsp @@ -3,6 +3,7 @@ * Edits made directly to this file will be lost. */ +import "../common"; import "../messages"; import "./custom.tsp"; @@ -34,10 +35,7 @@ model CreateThreadRequest { file_search?: ToolResourcesFileSearch; } | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; } model ModifyThreadRequest { @@ -57,10 +55,7 @@ model ModifyThreadRequest { file_search?: ToolResourcesFileSearchIdsOnly; } | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; } model DeleteThreadResponse { @@ -102,10 +97,7 @@ model ThreadObject { }; } | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata: Record | null; + ...MetadataPropertyForResponse; } model ListThreadsResponse { diff --git a/.typespec/vector-stores/models.tsp b/.typespec/vector-stores/models.tsp index be839732d..66ea3ff52 100644 --- a/.typespec/vector-stores/models.tsp +++ b/.typespec/vector-stores/models.tsp @@ -3,6 +3,7 @@ * Edits made directly to this file will be lost. */ +import "../common"; import "./custom.tsp"; using TypeSpec.OpenAPI; @@ -79,10 +80,7 @@ model VectorStoreObject { @encode("unixTimestamp", int32) last_active_at: utcDateTime | null; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata: Record | null; + ...MetadataPropertyForResponse; } model CreateVectorStoreRequest { @@ -103,10 +101,7 @@ model CreateVectorStoreRequest { @extension("x-oaiExpandable", true) chunking_strategy?: AutoChunkingStrategyRequestParam | StaticChunkingStrategyRequestParam; - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; } model UpdateVectorStoreRequest { @@ -114,11 +109,7 @@ model UpdateVectorStoreRequest { name?: string | null; expires_after?: VectorStoreExpirationAfter | null; - - // Tool customization: specialize known metadata string maps - /** Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. */ - @extension("x-oaiTypeLabel", "map") - metadata?: Record | null; + ...MetadataPropertyForRequest; } model ListVectorStoresResponse { diff --git a/README.md b/README.md index f913b25b8..1039d52af 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,16 @@ https://dev.azure.com/project-argos/Sorento/_wiki/wikis/Sorento.wiki/3021/Genera Snapshot: $M ``` -commit 9ca412840f1554cc23857a6a2aa1e66c231a8b40 (HEAD -> master, origin/master) +commit 3852712e812b9b16ab67bf4f390345a19f98aabd (HEAD -> master, origin/master) Author: root -Date: Wed Jan 22 19:03:08 2025 +0000 +Date: Fri Jan 31 21:29:23 2025 +0000 ``` Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk ``` -commit 7ec86ce9fbb544f7542979b601aaaec8c37263f6 (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) +commit 8b8856f854f166b9dbb80f60bf2d9f5ca8830f2f (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) Author: Travis Wilson -Date: Wed Jan 22 12:43:20 2025 -0800 +Date: Fri Jan 31 16:47:07 2025 -0800 ``` There are some deltas: diff --git a/openapi3-original.yaml b/openapi3-original.yaml index 1a259698a..d8e91b9e0 100644 --- a/openapi3-original.yaml +++ b/openapi3-original.yaml @@ -984,11 +984,7 @@ paths: description: The time frame within which the batch should be processed. Currently only `24h` is supported. metadata: - type: object - additionalProperties: - type: string - description: Optional custom metadata for the batch. - nullable: true + $ref: "#/components/schemas/Metadata" responses: "200": description: Batch created successfully. @@ -6859,6 +6855,14 @@ paths: required: false schema: type: string + - name: emails + in: query + description: Filter by the email address of users. + required: false + schema: + type: array + items: + type: string responses: "200": description: Users listed successfully. @@ -11262,14 +11266,7 @@ components: type: string nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" temperature: description: > What sampling temperature to use, between 0 and 2. Higher values @@ -12089,14 +12086,7 @@ components: - failed description: The request counts for different statuses within the batch. metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" required: - id - object @@ -13259,15 +13249,7 @@ components: - static x-oaiExpandable: true metadata: - type: object - description: > - Set of 16 key-value pairs that can be attached to a - vector store. This can be useful for storing - additional information about the vector store in a - structured format. Keys can be a maximum of 64 - characters long and values can be a maximum of 512 - characters long. - x-oaiTypeLabel: map + $ref: "#/components/schemas/Metadata" oneOf: - required: - vector_store_ids @@ -13275,14 +13257,7 @@ components: - vector_stores nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" temperature: description: > What sampling temperature to use, between 0 and 2. Higher values @@ -13486,6 +13461,8 @@ components: - type: string - type: string enum: + - o3-mini + - o3-mini-2025-01-31 - o1 - o1-2024-12-17 - o1-preview @@ -13558,13 +13535,7 @@ components: on reasoning in a response. metadata: - type: object - nullable: true - description: | - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - additionalProperties: - type: string + $ref: "#/components/schemas/Metadata" frequency_penalty: type: number default: 0 @@ -13804,8 +13775,8 @@ components: parameter is relevant for customers subscribed to the scale tier service: - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. + - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. - When not set, the default behavior is 'auto'. type: string enum: @@ -15243,14 +15214,7 @@ components: - tools nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" CreateModerationRequest: type: object properties: @@ -15793,14 +15757,7 @@ components: - $ref: "#/components/schemas/AssistantToolsFunction" x-oaiExpandable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" temperature: type: number minimum: 0 @@ -16028,14 +15985,7 @@ components: type: string nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" temperature: type: number minimum: 0 @@ -16230,15 +16180,7 @@ components: - static x-oaiExpandable: true metadata: - type: object - description: > - Set of 16 key-value pairs that can be attached to a - vector store. This can be useful for storing - additional information about the vector store in a - structured format. Keys can be a maximum of 64 - characters long and values can be a maximum of 512 - characters long. - x-oaiTypeLabel: map + $ref: "#/components/schemas/Metadata" x-oaiExpandable: true oneOf: - required: @@ -16247,14 +16189,7 @@ components: - vector_stores nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" CreateTranscriptionRequest: type: object additionalProperties: false @@ -16282,7 +16217,7 @@ components: description: > The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) - format will improve accuracy and latency. + (e.g. `en`) format will improve accuracy and latency. type: string prompt: description: > @@ -16558,14 +16493,7 @@ components: - $ref: "#/components/schemas/StaticChunkingStrategyRequestParam" x-oaiExpandable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" DefaultProjectErrorResponse: type: object properties: @@ -18653,14 +18581,7 @@ components: added to. nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" required: - id - object @@ -18801,6 +18722,25 @@ components: before it is completed. x-oaiMeta: dataDescription: "`data` is a [message](/docs/api-reference/messages/object)" + Metadata: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This can be + + useful for storing additional information about the object in a + structured + + format, and querying for objects via API or the dashboard. + + + Keys are strings with a maximum length of 64 characters. Values are + strings + + with a maximum length of 512 characters. + additionalProperties: + type: string + x-oaiTypeLabel: map + nullable: true Model: title: Model description: Describes an OpenAI model offering that can be used with the API. @@ -18916,14 +18856,7 @@ components: type: string nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" temperature: description: > What sampling temperature to use, between 0 and 2. Higher values @@ -18959,27 +18892,13 @@ components: additionalProperties: false properties: metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" ModifyRunRequest: type: object additionalProperties: false properties: metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" ModifyThreadRequest: type: object additionalProperties: false @@ -19019,14 +18938,7 @@ components: type: string nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" OpenAIFile: title: OpenAIFile description: The `File` object represents a document that has been uploaded to OpenAI. @@ -20419,12 +20331,7 @@ components: items: $ref: "#/components/schemas/RealtimeConversationItem" metadata: - description: > - Developer-provided string key-value pairs associated with this - response. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" usage: type: object description: > @@ -20483,6 +20390,85 @@ components: audio_tokens: type: integer description: The number of audio tokens used in the Response. + conversation_id: + description: > + Which conversation the response is added to, determined by the + `conversation` + + field in the `response.create` event. If `auto`, the response will + be added to + + the default conversation and the value of `conversation_id` will be + an id like + + `conv_1234`. If `none`, the response will not be added to any + conversation and + + the value of `conversation_id` will be `null`. If responses are + being triggered + + by server VAD, the response will be added to the default + conversation, thus + + the `conversation_id` will be an id like `conv_1234`. + type: string + voice: + type: string + enum: + - alloy + - ash + - ballad + - coral + - echo + - sage + - shimmer + - verse + description: > + The voice the model used to respond. + + Current voice options are `alloy`, `ash`, `ballad`, `coral`, `echo` + `sage`, + + `shimmer` and `verse`. + modalities: + type: array + description: > + The set of modalities the model used to respond. If there are + multiple modalities, + + the model will pick one, for example if `modalities` is `["text", + "audio"]`, the model + + could be responding in either text or audio. + items: + type: string + enum: + - text + - audio + output_audio_format: + type: string + enum: + - pcm16 + - g711_ulaw + - g711_alaw + description: > + The format of output audio. Options are `pcm16`, `g711_ulaw`, or + `g711_alaw`. + temperature: + type: number + description: > + Sampling temperature for the model, limited to [0.6, 1.2]. Defaults + to 0.8. + max_output_tokens: + oneOf: + - type: integer + - type: string + enum: + - inf + x-stainless-const: true + description: | + Maximum number of output tokens for a single assistant response, + inclusive of tool calls, that was used in this response. RealtimeResponseCreateParams: type: object description: Create a new Realtime response with these parameters @@ -20635,20 +20621,7 @@ components: - auto - none metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be - - useful for storing additional information about the object in a - structured - - format. Keys can be a maximum of 64 characters long and values can - be a - - maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" input: type: array description: > @@ -22507,20 +22480,8 @@ components: For `pcm16`, output audio is sampled at a rate of 24kHz. input_audio_transcription: type: object - description: > - Configuration for input audio transcription, defaults to off and can - be - - set to `null` to turn off once on. Input audio transcription is not - native - - to the model, since the model consumes audio directly. Transcription - runs - - asynchronously through Whisper and should be treated as rough - guidance - - rather than the representation understood by the model. + description: | + Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as rough guidance rather than the representation understood by the model. The client can optionally set the language and prompt for transcription, these fields will be passed to the Whisper API. properties: model: type: string @@ -22529,6 +22490,22 @@ components: currently supported model. + language: + type: string + description: | + The language of the input audio. Supplying the input language in + [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format + will improve accuracy and latency. + prompt: + type: string + description: > + An optional text to guide the model's style or continue a + previous audio + + segment. The [prompt](/docs/guides/speech-to-text#prompting) + should match + + the audio language. turn_detection: type: object description: > @@ -22656,6 +22633,9 @@ components: expire after one minute. + required: + - value + - expires_at modalities: description: | The set of modalities the model can respond with. To disable audio, @@ -22845,6 +22825,8 @@ components: inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or `inf` for the maximum available tokens for a given model. Defaults to `inf`. + required: + - client_secret x-oaiMeta: name: The session object group: realtime @@ -23091,14 +23073,7 @@ components: - $ref: "#/components/schemas/AssistantToolsFunction" x-oaiExpandable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" usage: $ref: "#/components/schemas/RunCompletionUsage" temperature: @@ -23809,14 +23784,7 @@ components: type: integer nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" usage: $ref: "#/components/schemas/RunStepCompletionUsage" required: @@ -24305,14 +24273,7 @@ components: type: string nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" required: - id - object @@ -24461,14 +24422,7 @@ components: - $ref: "#/components/schemas/VectorStoreExpirationAfter" - nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" Upload: type: object title: Upload @@ -25399,14 +25353,7 @@ components: type: integer nullable: true metadata: - description: > - Set of 16 key-value pairs that can be attached to an object. This - can be useful for storing additional information about the object in - a structured format. Keys can be a maximum of 64 characters long and - values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true + $ref: "#/components/schemas/Metadata" required: - id - object From c012d96404a7c98d018adf2fa12cf736f650b27b Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Fri, 31 Jan 2025 18:52:36 -0800 Subject: [PATCH 34/44] PR feedback --- .dotnet/CHANGELOG.md | 4 +- .dotnet/api/OpenAI.netstandard2.0.cs | 30 ++++++------ .../ChatCompletionOptions.Serialization.cs | 2 +- .../src/Custom/Chat/ChatCompletionOptions.cs | 8 ++-- .dotnet/src/Custom/Chat/ChatMessageContent.cs | 2 +- .../Chat/ChatOutputTokenUsageDetails.cs | 4 +- ...gEffort.cs => ChatReasoningEffortLevel.cs} | 2 +- .../src/Custom/Chat/OpenAIChatModelFactory.cs | 4 +- .../Custom/Files/OpenAIFilesModelFactory.cs | 12 ++--- .../ConversationStatusDetails.cs | 2 +- .../ConversationTokenUsage.cs | 4 ++ .../ChatCompletionOptions.Serialization.cs | 13 ++--- .../Generated/Models/ChatCompletionOptions.cs | 4 +- ...atOutputTokenUsageDetails.Serialization.cs | 14 +++--- .../Models/ChatOutputTokenUsageDetails.cs | 6 +-- .../Generated/Models/ChatReasoningEffort.cs | 47 ------------------- .../Models/ChatReasoningEffortLevel.cs | 47 +++++++++++++++++++ .../ConversationTokenUsage.Serialization.cs | 32 ++++++------- .../Models/ConversationTokenUsage.cs | 6 +-- .dotnet/src/Generated/OpenAIModelFactory.cs | 12 ++--- .dotnet/tests/Chat/ChatSmokeTests.cs | 10 ++++ .dotnet/tests/Chat/ChatTests.cs | 35 +++++++++++--- .../RealtimeConversation/ConversationTests.cs | 3 ++ .scripts/Edit-Serialization.ps1 | 12 +++++ 24 files changed, 183 insertions(+), 132 deletions(-) rename .dotnet/src/Custom/Chat/{ChatReasoningEffort.cs => ChatReasoningEffortLevel.cs} (75%) delete mode 100644 .dotnet/src/Generated/Models/ChatReasoningEffort.cs create mode 100644 .dotnet/src/Generated/Models/ChatReasoningEffortLevel.cs diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index 5c9047c2a..1b31c393e 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -11,9 +11,9 @@ - References to prior assistant audio are provided via `OutputAudioReference` instances on the `AudioReference` property of `AssistantChatMessage`; `AssistantChatMessage(chatCompletion)` will automatically handle this, too - For more information, see the example in the README - Predicted output can be used with chat completion: the new `PredictedContent` property on `ChatCompletionOptions` can be populated with `ChatMessageContentPart` instances to substantially accelerate some varieties of requests. -- For `o1` and later models with reasoning capabilities: +- For `o3-mini`, `o1`, and later models with reasoning capabilities: - The new `DeveloperChatMessage`, which replaces `SystemChatMessage`, can be used to provide instructions to the model - - `ChatCompletionOptions` can specify a `ReasoningEffort` property to adjust the level of token consumption the model will attempt to apply + - `ChatCompletionOptions` can specify a `ReasoningEffortLevel` property to adjust the level of token consumption the model will attempt to apply ### `[Experimental]` Breaking changes diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 95926799e..d2565e36b 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1212,7 +1212,7 @@ public class ChatCompletionOptions : IJsonModel, IPersist public IDictionary Metadata { get; } public ChatMessageContent PredictedContent { get; set; } public float? PresencePenalty { get; set; } - public ChatReasoningEffort? ReasoningEffort { get; set; } + public ChatReasoningEffortLevel? ReasoningEffortLevel { get; set; } public ChatResponseFormat ResponseFormat { get; set; } public ChatResponseModalities ResponseModalities { get; set; } public long? Seed { get; set; } @@ -1411,26 +1411,26 @@ public class ChatOutputAudioReference : IJsonModel, IP public override readonly string ToString(); } public class ChatOutputTokenUsageDetails : IJsonModel, IPersistableModel { + public int AcceptedPredictionTokenCount { get; } public int AudioTokenCount { get; } - public int PredictionAcceptedTokenCount { get; } - public int PredictionRejectedTokenCount { get; } public int ReasoningTokenCount { get; } + public int RejectedPredictionTokenCount { get; } public static explicit operator ChatOutputTokenUsageDetails(ClientResult result); public static implicit operator BinaryContent(ChatOutputTokenUsageDetails chatOutputTokenUsageDetails); } - public readonly partial struct ChatReasoningEffort : IEquatable { - public ChatReasoningEffort(string value); - public static ChatReasoningEffort High { get; } - public static ChatReasoningEffort Low { get; } - public static ChatReasoningEffort Medium { get; } - public readonly bool Equals(ChatReasoningEffort other); + public readonly partial struct ChatReasoningEffortLevel : IEquatable { + public ChatReasoningEffortLevel(string value); + public static ChatReasoningEffortLevel High { get; } + public static ChatReasoningEffortLevel Low { get; } + public static ChatReasoningEffortLevel Medium { get; } + public readonly bool Equals(ChatReasoningEffortLevel other); [EditorBrowsable(EditorBrowsableState.Never)] public override readonly bool Equals(object obj); [EditorBrowsable(EditorBrowsableState.Never)] public override readonly int GetHashCode(); - public static bool operator ==(ChatReasoningEffort left, ChatReasoningEffort right); - public static implicit operator ChatReasoningEffort(string value); - public static bool operator !=(ChatReasoningEffort left, ChatReasoningEffort right); + public static bool operator ==(ChatReasoningEffortLevel left, ChatReasoningEffortLevel right); + public static implicit operator ChatReasoningEffortLevel(string value); + public static bool operator !=(ChatReasoningEffortLevel left, ChatReasoningEffortLevel right); public override readonly string ToString(); } public class ChatResponseFormat : IJsonModel, IPersistableModel { @@ -1778,7 +1778,7 @@ public class OpenAIFileCollection : ObjectModel.ReadOnlyCollection, } public static class OpenAIFilesModelFactory { public static FileDeletionResult FileDeletionResult(string fileId = null, bool deleted = false); - public static OpenAIFileCollection OpenAIFileCollection(IEnumerable items = null, string firstId = null, string lastId = null, bool hasMore = false); + public static OpenAIFileCollection OpenAIFileCollection(IEnumerable items = null); public static OpenAIFile OpenAIFileInfo(string id = null, int? sizeInBytes = null, DateTimeOffset createdAt = default, string filename = null, FilePurpose purpose = FilePurpose.Assistants, FileStatus status = FileStatus.Uploaded, string statusDetails = null); } } @@ -2551,7 +2551,7 @@ public class ConversationSessionStartedUpdate : ConversationUpdate, IJsonModel, IPersistableModel { public string ErrorCode { get; } - public string ErrorType { get; } + public string ErrorKind { get; } public ConversationIncompleteReason? IncompleteReason { get; } public ConversationStatus StatusKind { get; } public static explicit operator ConversationStatusDetails(ClientResult result); @@ -2562,7 +2562,7 @@ public class ConversationTokenUsage : IJsonModel, IPersi public ConversationInputTokenUsageDetails InputTokenDetails { get; } public int OutputTokenCount { get; } public ConversationOutputTokenUsageDetails OutputTokenDetails { get; } - public int? TotalTokens { get; } + public int TotalTokenCount { get; } public static explicit operator ConversationTokenUsage(ClientResult result); public static implicit operator BinaryContent(ConversationTokenUsage conversationTokenUsage); } diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs index 4ead2afc5..0fe81bb76 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs @@ -99,7 +99,7 @@ private static void DeserializeLogitBiasesValue(JsonProperty property, ref IDict [MethodImpl(MethodImplOptions.AggressiveInlining)] private void SerializePredictedContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - if (PredictedContent is not null) + if (PredictedContent is not null && PredictedContent.IsInnerCollectionDefined()) { writer.WriteStartObject(); writer.WritePropertyName("type"u8); diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs index ab230daa3..a2c61d520 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs @@ -178,12 +178,14 @@ public ChatCompletionOptions() [CodeGenMember("Store")] public bool? StoredOutputEnabled { get; set; } + // CUSTOM: Renamed. /// /// (o1 and newer reasoning models only) Constrains effort on reasoning for reasoning models. - /// Currently supported values are , , and . + /// Currently supported values are , , and . /// Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. /// - public ChatReasoningEffort? ReasoningEffort { get; set; } + [CodeGenMember("ReasoningEffort")] + public ChatReasoningEffortLevel? ReasoningEffortLevel { get; set; } // CUSTOM: Made internal for automatic enablement via audio options. [CodeGenMember("Modalities")] @@ -220,5 +222,5 @@ public ChatAudioOptions AudioOptions } [CodeGenMember("Prediction")] - public ChatMessageContent PredictedContent { get; set; } + public ChatMessageContent PredictedContent { get; set; } = new(); } diff --git a/.dotnet/src/Custom/Chat/ChatMessageContent.cs b/.dotnet/src/Custom/Chat/ChatMessageContent.cs index f7a63114d..54868ae32 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContent.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContent.cs @@ -9,7 +9,7 @@ namespace OpenAI.Chat; public partial class ChatMessageContent : Collection { public ChatMessageContent() - : this(Array.Empty()) + : base(new ChangeTrackingList()) { } diff --git a/.dotnet/src/Custom/Chat/ChatOutputTokenUsageDetails.cs b/.dotnet/src/Custom/Chat/ChatOutputTokenUsageDetails.cs index b357a272c..27bac3698 100644 --- a/.dotnet/src/Custom/Chat/ChatOutputTokenUsageDetails.cs +++ b/.dotnet/src/Custom/Chat/ChatOutputTokenUsageDetails.cs @@ -16,8 +16,8 @@ public partial class ChatOutputTokenUsageDetails public int AudioTokenCount { get; } [CodeGenMember("AcceptedPredictionTokens")] - public int PredictionAcceptedTokenCount { get; } + public int AcceptedPredictionTokenCount { get; } [CodeGenMember("RejectedPredictionTokens")] - public int PredictionRejectedTokenCount { get; } + public int RejectedPredictionTokenCount { get; } } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatReasoningEffort.cs b/.dotnet/src/Custom/Chat/ChatReasoningEffortLevel.cs similarity index 75% rename from .dotnet/src/Custom/Chat/ChatReasoningEffort.cs rename to .dotnet/src/Custom/Chat/ChatReasoningEffortLevel.cs index 4a6556339..8f11b7d71 100644 --- a/.dotnet/src/Custom/Chat/ChatReasoningEffort.cs +++ b/.dotnet/src/Custom/Chat/ChatReasoningEffortLevel.cs @@ -5,5 +5,5 @@ namespace OpenAI.Chat; [CodeGenModel("CreateChatCompletionRequestReasoningEffort")] -public readonly partial struct ChatReasoningEffort +public readonly partial struct ChatReasoningEffortLevel {} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs index 9977980e4..81240a87a 100644 --- a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs +++ b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -121,8 +121,8 @@ public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reason return new ChatOutputTokenUsageDetails( audioTokenCount: audioTokenCount, reasoningTokenCount: reasoningTokenCount, - predictionAcceptedTokenCount: predictionAcceptedTokenCount, - predictionRejectedTokenCount: predictionRejectedTokenCount, + acceptedPredictionTokenCount: predictionAcceptedTokenCount, + rejectedPredictionTokenCount: predictionRejectedTokenCount, additionalBinaryDataProperties: null); } diff --git a/.dotnet/src/Custom/Files/OpenAIFilesModelFactory.cs b/.dotnet/src/Custom/Files/OpenAIFilesModelFactory.cs index af7e98052..78242157d 100644 --- a/.dotnet/src/Custom/Files/OpenAIFilesModelFactory.cs +++ b/.dotnet/src/Custom/Files/OpenAIFilesModelFactory.cs @@ -36,14 +36,12 @@ public static OpenAIFile OpenAIFileInfo(string id = null, int? sizeInBytes = nul /// Initializes a new instance of . /// A new instance for mocking. - public static OpenAIFileCollection OpenAIFileCollection(IEnumerable items = null, string firstId = default, string lastId = default, bool hasMore = default) + public static OpenAIFileCollection OpenAIFileCollection(IEnumerable items = null) { - items ??= new List(); - return new OpenAIFileCollection( - items.ToList(), - firstId, - lastId, - hasMore); + items?.ToList() ?? [], + firstId: null, + lastId : null, + hasMore: false); } } diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationStatusDetails.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationStatusDetails.cs index 8cf1826f8..346eebd12 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ConversationStatusDetails.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationStatusDetails.cs @@ -14,7 +14,7 @@ public partial class ConversationStatusDetails [CodeGenMember("Reason")] public ConversationIncompleteReason? IncompleteReason { get; } - public string ErrorType => Error?.Type ?? string.Empty; + public string ErrorKind => Error?.Type ?? string.Empty; public string ErrorCode => Error?.Code ?? string.Empty; diff --git a/.dotnet/src/Custom/RealtimeConversation/ConversationTokenUsage.cs b/.dotnet/src/Custom/RealtimeConversation/ConversationTokenUsage.cs index 18ab0462b..1842c2b14 100644 --- a/.dotnet/src/Custom/RealtimeConversation/ConversationTokenUsage.cs +++ b/.dotnet/src/Custom/RealtimeConversation/ConversationTokenUsage.cs @@ -13,4 +13,8 @@ public partial class ConversationTokenUsage // CUSTOM: Renamed, nullability removed [CodeGenMember("OutputTokens")] public int OutputTokenCount { get; } + + // CUSTOM: Renamed, nullability removed + [CodeGenMember("TotalTokens")] + public int TotalTokenCount { get; } } \ No newline at end of file diff --git a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs index 3d096db75..49abeec67 100644 --- a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs @@ -278,12 +278,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteNull("store"u8); } } - if (Optional.IsDefined(ReasoningEffort) && _additionalBinaryDataProperties?.ContainsKey("reasoning_effort") != true) + if (Optional.IsDefined(ReasoningEffortLevel) && _additionalBinaryDataProperties?.ContainsKey("reasoning_effort") != true) { writer.WritePropertyName("reasoning_effort"u8); - writer.WriteStringValue(ReasoningEffort.Value.ToString()); + writer.WriteStringValue(ReasoningEffortLevel.Value.ToString()); } - if (Optional.IsDefined(PredictedContent) && _additionalBinaryDataProperties?.ContainsKey("prediction") != true) + // CUSTOM: Check inner collection is defined. + if (Optional.IsDefined(PredictedContent) && PredictedContent.IsInnerCollectionDefined() && _additionalBinaryDataProperties?.ContainsKey("prediction") != true) { if (PredictedContent != null) { @@ -401,7 +402,7 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme IList functions = default; IDictionary metadata = default; bool? storedOutputEnabled = default; - ChatReasoningEffort? reasoningEffort = default; + ChatReasoningEffortLevel? reasoningEffortLevel = default; ChatMessageContent predictedContent = default; InternalCreateChatCompletionRequestServiceTier? serviceTier = default; IList internalModalities = default; @@ -660,7 +661,7 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme { continue; } - reasoningEffort = new ChatReasoningEffort(prop.Value.GetString()); + reasoningEffortLevel = new ChatReasoningEffortLevel(prop.Value.GetString()); continue; } if (prop.NameEquals("prediction"u8)) @@ -733,7 +734,7 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme functions ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), storedOutputEnabled, - reasoningEffort, + reasoningEffortLevel, predictedContent, serviceTier, internalModalities, diff --git a/.dotnet/src/Generated/Models/ChatCompletionOptions.cs b/.dotnet/src/Generated/Models/ChatCompletionOptions.cs index 8718d1892..a5e82ba26 100644 --- a/.dotnet/src/Generated/Models/ChatCompletionOptions.cs +++ b/.dotnet/src/Generated/Models/ChatCompletionOptions.cs @@ -11,7 +11,7 @@ public partial class ChatCompletionOptions { private protected IDictionary _additionalBinaryDataProperties; - internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, ChatResponseFormat responseFormat, float? temperature, float? topP, IList tools, IList messages, InternalCreateChatCompletionRequestModel model, int? n, bool? stream, InternalChatCompletionStreamOptions streamOptions, bool? includeLogProbabilities, int? topLogProbabilityCount, IList stopSequences, IDictionary logitBiases, ChatToolChoice toolChoice, ChatFunctionChoice functionChoice, bool? allowParallelToolCalls, string endUserId, long? seed, int? deprecatedMaxTokens, int? maxOutputTokenCount, IList functions, IDictionary metadata, bool? storedOutputEnabled, ChatReasoningEffort? reasoningEffort, ChatMessageContent predictedContent, InternalCreateChatCompletionRequestServiceTier? serviceTier, IList internalModalities, ChatAudioOptions audioOptions, IDictionary additionalBinaryDataProperties) + internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, ChatResponseFormat responseFormat, float? temperature, float? topP, IList tools, IList messages, InternalCreateChatCompletionRequestModel model, int? n, bool? stream, InternalChatCompletionStreamOptions streamOptions, bool? includeLogProbabilities, int? topLogProbabilityCount, IList stopSequences, IDictionary logitBiases, ChatToolChoice toolChoice, ChatFunctionChoice functionChoice, bool? allowParallelToolCalls, string endUserId, long? seed, int? deprecatedMaxTokens, int? maxOutputTokenCount, IList functions, IDictionary metadata, bool? storedOutputEnabled, ChatReasoningEffortLevel? reasoningEffortLevel, ChatMessageContent predictedContent, InternalCreateChatCompletionRequestServiceTier? serviceTier, IList internalModalities, ChatAudioOptions audioOptions, IDictionary additionalBinaryDataProperties) { FrequencyPenalty = frequencyPenalty; PresencePenalty = presencePenalty; @@ -38,7 +38,7 @@ internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, Functions = functions; Metadata = metadata; StoredOutputEnabled = storedOutputEnabled; - ReasoningEffort = reasoningEffort; + ReasoningEffortLevel = reasoningEffortLevel; PredictedContent = predictedContent; _serviceTier = serviceTier; _internalModalities = internalModalities; diff --git a/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs b/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs index c714cd457..12d22dfe8 100644 --- a/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs @@ -40,12 +40,12 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("accepted_prediction_tokens") != true) { writer.WritePropertyName("accepted_prediction_tokens"u8); - writer.WriteNumberValue(PredictionAcceptedTokenCount); + writer.WriteNumberValue(AcceptedPredictionTokenCount); } if (_additionalBinaryDataProperties?.ContainsKey("rejected_prediction_tokens") != true) { writer.WritePropertyName("rejected_prediction_tokens"u8); - writer.WriteNumberValue(PredictionRejectedTokenCount); + writer.WriteNumberValue(RejectedPredictionTokenCount); } if (true && _additionalBinaryDataProperties != null) { @@ -89,8 +89,8 @@ internal static ChatOutputTokenUsageDetails DeserializeChatOutputTokenUsageDetai } int reasoningTokenCount = default; int audioTokenCount = default; - int predictionAcceptedTokenCount = default; - int predictionRejectedTokenCount = default; + int acceptedPredictionTokenCount = default; + int rejectedPredictionTokenCount = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { @@ -118,7 +118,7 @@ internal static ChatOutputTokenUsageDetails DeserializeChatOutputTokenUsageDetai { continue; } - predictionAcceptedTokenCount = prop.Value.GetInt32(); + acceptedPredictionTokenCount = prop.Value.GetInt32(); continue; } if (prop.NameEquals("rejected_prediction_tokens"u8)) @@ -127,7 +127,7 @@ internal static ChatOutputTokenUsageDetails DeserializeChatOutputTokenUsageDetai { continue; } - predictionRejectedTokenCount = prop.Value.GetInt32(); + rejectedPredictionTokenCount = prop.Value.GetInt32(); continue; } if (true) @@ -135,7 +135,7 @@ internal static ChatOutputTokenUsageDetails DeserializeChatOutputTokenUsageDetai additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, predictionAcceptedTokenCount, predictionRejectedTokenCount, additionalBinaryDataProperties); + return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, acceptedPredictionTokenCount, rejectedPredictionTokenCount, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.cs b/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.cs index 93ea0dba5..15e3f963c 100644 --- a/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.cs +++ b/.dotnet/src/Generated/Models/ChatOutputTokenUsageDetails.cs @@ -15,12 +15,12 @@ internal ChatOutputTokenUsageDetails() { } - internal ChatOutputTokenUsageDetails(int reasoningTokenCount, int audioTokenCount, int predictionAcceptedTokenCount, int predictionRejectedTokenCount, IDictionary additionalBinaryDataProperties) + internal ChatOutputTokenUsageDetails(int reasoningTokenCount, int audioTokenCount, int acceptedPredictionTokenCount, int rejectedPredictionTokenCount, IDictionary additionalBinaryDataProperties) { ReasoningTokenCount = reasoningTokenCount; AudioTokenCount = audioTokenCount; - PredictionAcceptedTokenCount = predictionAcceptedTokenCount; - PredictionRejectedTokenCount = predictionRejectedTokenCount; + AcceptedPredictionTokenCount = acceptedPredictionTokenCount; + RejectedPredictionTokenCount = rejectedPredictionTokenCount; _additionalBinaryDataProperties = additionalBinaryDataProperties; } diff --git a/.dotnet/src/Generated/Models/ChatReasoningEffort.cs b/.dotnet/src/Generated/Models/ChatReasoningEffort.cs deleted file mode 100644 index a4b79fce4..000000000 --- a/.dotnet/src/Generated/Models/ChatReasoningEffort.cs +++ /dev/null @@ -1,47 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Chat -{ - public readonly partial struct ChatReasoningEffort : IEquatable - { - private readonly string _value; - private const string LowValue = "low"; - private const string MediumValue = "medium"; - private const string HighValue = "high"; - - public ChatReasoningEffort(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static ChatReasoningEffort Low { get; } = new ChatReasoningEffort(LowValue); - - public static ChatReasoningEffort Medium { get; } = new ChatReasoningEffort(MediumValue); - - public static ChatReasoningEffort High { get; } = new ChatReasoningEffort(HighValue); - - public static bool operator ==(ChatReasoningEffort left, ChatReasoningEffort right) => left.Equals(right); - - public static bool operator !=(ChatReasoningEffort left, ChatReasoningEffort right) => !left.Equals(right); - - public static implicit operator ChatReasoningEffort(string value) => new ChatReasoningEffort(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ChatReasoningEffort other && Equals(other); - - public bool Equals(ChatReasoningEffort other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/ChatReasoningEffortLevel.cs b/.dotnet/src/Generated/Models/ChatReasoningEffortLevel.cs new file mode 100644 index 000000000..4055fb2ef --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatReasoningEffortLevel.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + public readonly partial struct ChatReasoningEffortLevel : IEquatable + { + private readonly string _value; + private const string LowValue = "low"; + private const string MediumValue = "medium"; + private const string HighValue = "high"; + + public ChatReasoningEffortLevel(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static ChatReasoningEffortLevel Low { get; } = new ChatReasoningEffortLevel(LowValue); + + public static ChatReasoningEffortLevel Medium { get; } = new ChatReasoningEffortLevel(MediumValue); + + public static ChatReasoningEffortLevel High { get; } = new ChatReasoningEffortLevel(HighValue); + + public static bool operator ==(ChatReasoningEffortLevel left, ChatReasoningEffortLevel right) => left.Equals(right); + + public static bool operator !=(ChatReasoningEffortLevel left, ChatReasoningEffortLevel right) => !left.Equals(right); + + public static implicit operator ChatReasoningEffortLevel(string value) => new ChatReasoningEffortLevel(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatReasoningEffortLevel other && Equals(other); + + public bool Equals(ChatReasoningEffortLevel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs b/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs index d67cd3b3a..e7c45e9e6 100644 --- a/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs +++ b/.dotnet/src/Generated/Models/ConversationTokenUsage.Serialization.cs @@ -27,11 +27,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(ConversationTokenUsage)} does not support writing '{format}' format."); } - if (Optional.IsDefined(TotalTokens) && _additionalBinaryDataProperties?.ContainsKey("total_tokens") != true) - { - writer.WritePropertyName("total_tokens"u8); - writer.WriteNumberValue(TotalTokens.Value); - } if (Optional.IsDefined(InputTokenDetails) && _additionalBinaryDataProperties?.ContainsKey("input_token_details") != true) { writer.WritePropertyName("input_token_details"u8); @@ -52,6 +47,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("output_tokens"u8); writer.WriteNumberValue(OutputTokenCount); } + if (_additionalBinaryDataProperties?.ContainsKey("total_tokens") != true) + { + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokenCount); + } if (true && _additionalBinaryDataProperties != null) { foreach (var item in _additionalBinaryDataProperties) @@ -92,23 +92,14 @@ internal static ConversationTokenUsage DeserializeConversationTokenUsage(JsonEle { return null; } - int? totalTokens = default; ConversationInputTokenUsageDetails inputTokenDetails = default; ConversationOutputTokenUsageDetails outputTokenDetails = default; int inputTokenCount = default; int outputTokenCount = default; + int totalTokenCount = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("total_tokens"u8)) - { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - totalTokens = prop.Value.GetInt32(); - continue; - } if (prop.NameEquals("input_token_details"u8)) { if (prop.Value.ValueKind == JsonValueKind.Null) @@ -145,17 +136,26 @@ internal static ConversationTokenUsage DeserializeConversationTokenUsage(JsonEle outputTokenCount = prop.Value.GetInt32(); continue; } + if (prop.NameEquals("total_tokens"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + totalTokenCount = prop.Value.GetInt32(); + continue; + } if (true) { additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } return new ConversationTokenUsage( - totalTokens, inputTokenDetails, outputTokenDetails, inputTokenCount, outputTokenCount, + totalTokenCount, additionalBinaryDataProperties); } diff --git a/.dotnet/src/Generated/Models/ConversationTokenUsage.cs b/.dotnet/src/Generated/Models/ConversationTokenUsage.cs index a5556fa21..4ea2214fd 100644 --- a/.dotnet/src/Generated/Models/ConversationTokenUsage.cs +++ b/.dotnet/src/Generated/Models/ConversationTokenUsage.cs @@ -15,18 +15,16 @@ internal ConversationTokenUsage() { } - internal ConversationTokenUsage(int? totalTokens, ConversationInputTokenUsageDetails inputTokenDetails, ConversationOutputTokenUsageDetails outputTokenDetails, int inputTokenCount, int outputTokenCount, IDictionary additionalBinaryDataProperties) + internal ConversationTokenUsage(ConversationInputTokenUsageDetails inputTokenDetails, ConversationOutputTokenUsageDetails outputTokenDetails, int inputTokenCount, int outputTokenCount, int totalTokenCount, IDictionary additionalBinaryDataProperties) { - TotalTokens = totalTokens; InputTokenDetails = inputTokenDetails; OutputTokenDetails = outputTokenDetails; InputTokenCount = inputTokenCount; OutputTokenCount = outputTokenCount; + TotalTokenCount = totalTokenCount; _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public int? TotalTokens { get; } - public ConversationInputTokenUsageDetails InputTokenDetails { get; } public ConversationOutputTokenUsageDetails OutputTokenDetails { get; } diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index eefd3e7d6..b7da06559 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -606,15 +606,15 @@ public static ConversationStatusDetails ConversationStatusDetails(ConversationSt return new ConversationStatusDetails(statusKind, incompleteReason, error, additionalBinaryDataProperties: null); } - public static ConversationTokenUsage ConversationTokenUsage(int? totalTokens = default, ConversationInputTokenUsageDetails inputTokenDetails = default, ConversationOutputTokenUsageDetails outputTokenDetails = default, int inputTokenCount = default, int outputTokenCount = default) + public static ConversationTokenUsage ConversationTokenUsage(ConversationInputTokenUsageDetails inputTokenDetails = default, ConversationOutputTokenUsageDetails outputTokenDetails = default, int inputTokenCount = default, int outputTokenCount = default, int totalTokenCount = default) { return new ConversationTokenUsage( - totalTokens, inputTokenDetails, outputTokenDetails, inputTokenCount, outputTokenCount, + totalTokenCount, additionalBinaryDataProperties: null); } @@ -907,10 +907,10 @@ public static ChatTokenUsage ChatTokenUsage(int outputTokenCount = default, int additionalBinaryDataProperties: null); } - public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default, int audioTokenCount = default, int predictionAcceptedTokenCount = default, int predictionRejectedTokenCount = default) + public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default, int audioTokenCount = default, int acceptedPredictionTokenCount = default, int rejectedPredictionTokenCount = default) { - return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, predictionAcceptedTokenCount, predictionRejectedTokenCount, additionalBinaryDataProperties: null); + return new ChatOutputTokenUsageDetails(reasoningTokenCount, audioTokenCount, acceptedPredictionTokenCount, rejectedPredictionTokenCount, additionalBinaryDataProperties: null); } public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = default, int cachedTokenCount = default) @@ -919,7 +919,7 @@ public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTok return new ChatInputTokenUsageDetails(audioTokenCount, cachedTokenCount, additionalBinaryDataProperties: null); } - public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalty = default, float? presencePenalty = default, ChatResponseFormat responseFormat = default, float? temperature = default, float? topP = default, IEnumerable tools = default, IEnumerable messages = default, InternalCreateChatCompletionRequestModel model = default, int? n = default, bool? stream = default, InternalChatCompletionStreamOptions streamOptions = default, bool? includeLogProbabilities = default, int? topLogProbabilityCount = default, IEnumerable stopSequences = default, IDictionary logitBiases = default, ChatToolChoice toolChoice = default, ChatFunctionChoice functionChoice = default, bool? allowParallelToolCalls = default, string endUserId = default, long? seed = default, int? deprecatedMaxTokens = default, int? maxOutputTokenCount = default, IEnumerable functions = default, IDictionary metadata = default, bool? storedOutputEnabled = default, ChatReasoningEffort? reasoningEffort = default, ChatMessageContent predictedContent = default, InternalCreateChatCompletionRequestServiceTier? serviceTier = default, IEnumerable internalModalities = default, ChatAudioOptions audioOptions = default) + public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalty = default, float? presencePenalty = default, ChatResponseFormat responseFormat = default, float? temperature = default, float? topP = default, IEnumerable tools = default, IEnumerable messages = default, InternalCreateChatCompletionRequestModel model = default, int? n = default, bool? stream = default, InternalChatCompletionStreamOptions streamOptions = default, bool? includeLogProbabilities = default, int? topLogProbabilityCount = default, IEnumerable stopSequences = default, IDictionary logitBiases = default, ChatToolChoice toolChoice = default, ChatFunctionChoice functionChoice = default, bool? allowParallelToolCalls = default, string endUserId = default, long? seed = default, int? deprecatedMaxTokens = default, int? maxOutputTokenCount = default, IEnumerable functions = default, IDictionary metadata = default, bool? storedOutputEnabled = default, ChatReasoningEffortLevel? reasoningEffortLevel = default, ChatMessageContent predictedContent = default, InternalCreateChatCompletionRequestServiceTier? serviceTier = default, IEnumerable internalModalities = default, ChatAudioOptions audioOptions = default) { tools ??= new ChangeTrackingList(); messages ??= new ChangeTrackingList(); @@ -955,7 +955,7 @@ public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalt functions?.ToList(), metadata, storedOutputEnabled, - reasoningEffort, + reasoningEffortLevel, predictedContent, serviceTier, internalModalities?.ToList(), diff --git a/.dotnet/tests/Chat/ChatSmokeTests.cs b/.dotnet/tests/Chat/ChatSmokeTests.cs index c59e7dbc2..fc9c1f88b 100644 --- a/.dotnet/tests/Chat/ChatSmokeTests.cs +++ b/.dotnet/tests/Chat/ChatSmokeTests.cs @@ -906,4 +906,14 @@ public void TopLevelClientOptionsPersistence() Assert.That(observedEndpoint, Is.Not.Null); Assert.That(observedEndpoint.AbsoluteUri, Does.Contain("my.custom.com/expected/test/endpoint")); } + + [Test] + public void CanUseCollections() + { + ChatCompletionOptions options = new(); + Assert.That(options.Tools.Count, Is.EqualTo(0)); + Assert.That(options.Metadata.Count, Is.EqualTo(0)); + Assert.That(options.PredictedContent.Count, Is.EqualTo(0)); + Assert.That(options.StopSequences.Count, Is.EqualTo(0)); + } } diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index e7d73fdf6..d66ccd531 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -867,13 +867,15 @@ public async Task HelloWorldChatWithTracingAndMetrics() [Test] public async Task ReasoningTokensWork() { - ChatClient client = GetTestClient(TestScenario.Chat, "o1-mini"); + ChatClient client = GetTestClient(TestScenario.Chat, "o3-mini"); UserChatMessage message = new("Using a comprehensive evaluation of popular media in the 1970s and 1980s, what were the most common sci-fi themes?"); ChatCompletionOptions options = new() { - MaxOutputTokenCount = 2148 + MaxOutputTokenCount = 2148, + ReasoningEffortLevel = ChatReasoningEffortLevel.Low, }; + Assert.That(ModelReaderWriter.Write(options).ToString(), Does.Contain(@"""reasoning_effort"":""low""")); ClientResult completionResult = IsAsync ? await client.CompleteChatAsync([message], options) : client.CompleteChat([message], options); @@ -917,11 +919,11 @@ Modify the following input to enable the feature. Only respond with the JSON and ChatCompletion completion = await client.CompleteChatAsync([message], options); - Assert.That(completion.Usage.OutputTokenDetails.PredictionAcceptedTokenCount, Is.GreaterThan(0)); + Assert.That(completion.Usage.OutputTokenDetails.AcceptedPredictionTokenCount, Is.GreaterThan(0)); } [Test] - public async Task O1DeveloperMessagesWork() + public async Task O3miniDeveloperMessagesWork() { List messages = [ @@ -931,13 +933,34 @@ public async Task O1DeveloperMessagesWork() ChatCompletionOptions options = new() { - ReasoningEffort = ChatReasoningEffort.Low, + ReasoningEffortLevel = ChatReasoningEffortLevel.Low, }; - ChatClient client = GetTestClient(TestScenario.Chat, "o1"); + ChatClient client = GetTestClient(TestScenario.Chat, "o3-mini"); ChatCompletion completion = await client.CompleteChatAsync(messages, options); List expectedPossibles = ["arr", "matey", "hearty", "avast"]; Assert.That(expectedPossibles.Any(expected => completion.Content[0].Text.ToLower().Contains(expected))); } + + [Test] + public async Task ChatMetadata() + { + ChatClient client = GetTestClient(); + + ChatCompletionOptions options = new() + { + StoredOutputEnabled = true, + Metadata = + { + ["my_metadata_key"] = "my_metadata_value", + }, + }; + + ChatCompletion completion = await client.CompleteChatAsync( + ["Hello, world!"], + options); + } + + private static ChatClient GetTestClient(string overrideModel = null) => GetTestClient(TestScenario.Chat, overrideModel); } diff --git a/.dotnet/tests/RealtimeConversation/ConversationTests.cs b/.dotnet/tests/RealtimeConversation/ConversationTests.cs index e572d29bc..d993c128b 100644 --- a/.dotnet/tests/RealtimeConversation/ConversationTests.cs +++ b/.dotnet/tests/RealtimeConversation/ConversationTests.cs @@ -137,6 +137,9 @@ await session.AddItemAsync( if (update is ConversationResponseFinishedUpdate responseFinishedUpdate) { Assert.That(responseFinishedUpdate.CreatedItems, Has.Count.GreaterThan(0)); + Assert.That(responseFinishedUpdate.Usage?.TotalTokenCount, Is.GreaterThan(0)); + Assert.That(responseFinishedUpdate.Usage.InputTokenCount, Is.GreaterThan(0)); + Assert.That(responseFinishedUpdate.Usage.OutputTokenCount, Is.GreaterThan(0)); gotResponseDone = true; break; } diff --git a/.scripts/Edit-Serialization.ps1 b/.scripts/Edit-Serialization.ps1 index 0d1c06ffb..e72f40ff2 100644 --- a/.scripts/Edit-Serialization.ps1 +++ b/.scripts/Edit-Serialization.ps1 @@ -194,3 +194,15 @@ Update-In-File-With-Retry ` ) ` -OutputIndentation 12 ` -RequirePresence + +Update-In-File-With-Retry ` + -FilePath "$directory\ChatCompletionOptions.Serialization.cs" ` + -SearchPatternLines @( + "if \(Optional\.IsDefined\(PredictedContent\) && _additionalBinaryDataProperties\?\.ContainsKey\(`"prediction`"\) != true\)" + ) ` + -ReplacePatternLines @( + "// CUSTOM: Check inner collection is defined." + "if (Optional.IsDefined(PredictedContent) && PredictedContent.IsInnerCollectionDefined() && _additionalBinaryDataProperties?.ContainsKey(`"prediction`") != true)" + ) ` + -OutputIndentation 12 ` + -RequirePresence From c25244ffabf1676c5d685a8361043f1153ede5c4 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Mon, 3 Feb 2025 17:17:06 -0800 Subject: [PATCH 35/44] minor: flush replicated changes from azure-sdk-for-net stage --- .dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md | 9 ++++++--- .../src/Custom/Chat/UserSecurityContext.cs | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md index d77cb734b..6d4a09fbd 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md @@ -1,12 +1,15 @@ # Release History -## 2.2.0-beta.1 (Unreleased) +## 2.2.0-beta.1 (2025-02-04) This preview release aligns with the corresponding `2.2.0` beta of `OpenAI` and the `2025-01-01-Preview` Azure OpenAI Service API version. -New features include: +New features include since 2.1.0-beta.2 include: -- To be filled +- Audio input for Chat Completions using `gpt-4o-audio-preview` or other compatible models: provide input audio via `ChatMessageContentPart.CreateInputAudioPart()`, set `AudioOptions` and `ResponseModalities` on `ChatCompletionOptions`, retrieve response audio via `OutputAudio` on `ChatCompletion`, and reference audio history from the assistant by using the `AssistantChatMessage(ChatCompletion)` constructor or using `ChatMessageContentPart.CreateAudioPart(string)`. For more information, refer to the examples in [the OpenAI README](https://github.com/openai/openai-dotnet/blob/main/README.md). +- Predicted outputs in Chat Completions: `ChatCompletionOptions` accepts a distinct `PredictedContent` collection (only text items) that can be used to optimize completion efficiency for scenarios like code completion. For more information, see [OpenAI's predicted outputs announcement](https://community.openai.com/t/introducing-predicted-outputs/1004502). +- Chat Completions `o`-series model feature support: the new `developer` message role via `DeveloperChatMessage` (used just like `SystemChatMessage`), `ReasoningEffortLevel` on Chat Completion options +- [AOAI exclusive] `UserSecurityContext` integration with [Defender for Cloud](https://learn.microsoft.com/azure/defender-for-cloud/gain-end-user-context-ai); add a `UserSecurityContext` instance to `ChatCompletionOptions` with `SetUserSecurityContext()` ### Breaking Changes diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs index a53431959..c657ba7b2 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -8,7 +11,7 @@ namespace Azure.AI.OpenAI; [CodeGenModel("AzureUserSecurityContext")] [Experimental("AOAI001")] public partial class UserSecurityContext -{ +{ /// The name of the application. Sensitive personal information should not be included in this field. public string ApplicationName { get; set;} /// This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. From fbc943ebc3ef0a10d0325ce6c93d44e08762e2f5 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Mon, 3 Feb 2025 18:39:54 -0800 Subject: [PATCH 36/44] PR feedback: new OutputPrediction instead of PredictedContent --- .dotnet/CHANGELOG.md | 2 +- .dotnet/api/OpenAI.netstandard2.0.cs | 22 ++- .../ChatCompletionOptions.Serialization.cs | 37 ---- .../src/Custom/Chat/ChatCompletionOptions.cs | 4 +- .../Custom/Chat/ChatMessage.Serialization.cs | 23 +-- .dotnet/src/Custom/Chat/ChatMessage.cs | 1 - .../Chat/ChatMessageContent.Serialization.cs | 50 ++++++ .../src/Custom/Chat/ChatOutputPrediction.cs | 19 ++ .../Custom/Chat/ChatOutputPredictionKind.cs | 13 ++ .../Custom/Chat/Internal/GeneratorStubs.cs | 7 +- ...CompletionResponseMessage.Serialization.cs | 22 +-- .../InternalChatCompletionResponseMessage.cs | 1 - ...letionStreamResponseDelta.Serialization.cs | 22 +-- ...ternalChatCompletionStreamResponseDelta.cs | 1 - ...atOutputPredictionContent.Serialization.cs | 22 +++ .../InternalChatOutputPredictionContent.cs | 15 ++ .../Custom/Chat/InternalPredictionContent.cs | 13 ++ .../ChatCompletionOptions.Serialization.cs | 18 +- .../Generated/Models/ChatCompletionOptions.cs | 4 +- .../ChatOutputPrediction.Serialization.cs | 139 +++++++++++++++ .../Generated/Models/ChatOutputPrediction.cs | 31 ++++ .../Models/ChatOutputPredictionKind.cs | 39 +++++ ...atOutputPredictionContent.Serialization.cs | 134 ++++++++++++++ .../InternalChatOutputPredictionContent.cs | 25 +++ ...InternalPredictionContent.Serialization.cs | 163 ------------------ .../Models/InternalPredictionContent.cs | 39 ----- .../Models/InternalPredictionContentType.cs | 41 ----- ...knownChatOutputPrediction.Serialization.cs | 105 +++++++++++ .../InternalUnknownChatOutputPrediction.cs | 16 ++ .dotnet/src/Generated/OpenAIModelFactory.cs | 10 +- .dotnet/tests/Chat/ChatSmokeTests.cs | 1 - .dotnet/tests/Chat/ChatTests.cs | 53 ++++-- .openapi3/openapi3-openai.yaml | 74 +++++--- .scripts/Edit-Serialization.ps1 | 6 +- .scripts/Remove-Abstract.ps1 | 4 +- .typespec/chat/custom.tsp | 8 + .typespec/chat/models.tsp | 6 +- README.md | 4 +- 38 files changed, 783 insertions(+), 411 deletions(-) create mode 100644 .dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs create mode 100644 .dotnet/src/Custom/Chat/ChatOutputPrediction.cs create mode 100644 .dotnet/src/Custom/Chat/ChatOutputPredictionKind.cs create mode 100644 .dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionContent.Serialization.cs create mode 100644 .dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionContent.cs create mode 100644 .dotnet/src/Custom/Chat/InternalPredictionContent.cs create mode 100644 .dotnet/src/Generated/Models/ChatOutputPrediction.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/ChatOutputPrediction.cs create mode 100644 .dotnet/src/Generated/Models/ChatOutputPredictionKind.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatOutputPredictionContent.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatOutputPredictionContent.cs delete mode 100644 .dotnet/src/Generated/Models/InternalPredictionContent.Serialization.cs delete mode 100644 .dotnet/src/Generated/Models/InternalPredictionContent.cs delete mode 100644 .dotnet/src/Generated/Models/InternalPredictionContentType.cs create mode 100644 .dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.cs diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index 1b31c393e..9854cf260 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -10,7 +10,7 @@ - Output chat audio is provided on the `OutputAudio` property of `ChatCompletion` - References to prior assistant audio are provided via `OutputAudioReference` instances on the `AudioReference` property of `AssistantChatMessage`; `AssistantChatMessage(chatCompletion)` will automatically handle this, too - For more information, see the example in the README -- Predicted output can be used with chat completion: the new `PredictedContent` property on `ChatCompletionOptions` can be populated with `ChatMessageContentPart` instances to substantially accelerate some varieties of requests. +- Predicted output can be used with chat completion: the new `OutputPrediction` property on `ChatCompletionOptions` can be populated with `ChatMessageContentPart` instances via `ChatOutputPrediction.CreateStaticContentPrediction()` to substantially accelerate some varieties of requests. - For `o3-mini`, `o1`, and later models with reasoning capabilities: - The new `DeveloperChatMessage`, which replaces `SystemChatMessage`, can be used to provide instructions to the model - `ChatCompletionOptions` can specify a `ReasoningEffortLevel` property to adjust the level of token consumption the model will attempt to apply diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index d2565e36b..500959bb6 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1210,7 +1210,7 @@ public class ChatCompletionOptions : IJsonModel, IPersist public IDictionary LogitBiases { get; } public int? MaxOutputTokenCount { get; set; } public IDictionary Metadata { get; } - public ChatMessageContent PredictedContent { get; set; } + public ChatOutputPrediction OutputPrediction { get; set; } public float? PresencePenalty { get; set; } public ChatReasoningEffortLevel? ReasoningEffortLevel { get; set; } public ChatResponseFormat ResponseFormat { get; set; } @@ -1410,6 +1410,26 @@ public class ChatOutputAudioReference : IJsonModel, IP public static bool operator !=(ChatOutputAudioVoice left, ChatOutputAudioVoice right); public override readonly string ToString(); } + public class ChatOutputPrediction : IJsonModel, IPersistableModel { + public ChatOutputPredictionKind Kind { get; } + public static ChatOutputPrediction CreateStaticContentPrediction(IEnumerable contentParts); + public static ChatOutputPrediction CreateStaticContentPrediction(string content); + public static explicit operator ChatOutputPrediction(ClientResult result); + public static implicit operator BinaryContent(ChatOutputPrediction chatOutputPrediction); + } + public readonly partial struct ChatOutputPredictionKind : IEquatable { + public ChatOutputPredictionKind(string value); + public static ChatOutputPredictionKind StaticContent { get; } + public readonly bool Equals(ChatOutputPredictionKind other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(ChatOutputPredictionKind left, ChatOutputPredictionKind right); + public static implicit operator ChatOutputPredictionKind(string value); + public static bool operator !=(ChatOutputPredictionKind left, ChatOutputPredictionKind right); + public override readonly string ToString(); + } public class ChatOutputTokenUsageDetails : IJsonModel, IPersistableModel { public int AcceptedPredictionTokenCount { get; } public int AudioTokenCount { get; } diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs index 0fe81bb76..cc003e4b4 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.Serialization.cs @@ -95,41 +95,4 @@ private static void DeserializeLogitBiasesValue(JsonProperty property, ref IDict logitBias = dictionary; } } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void SerializePredictedContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - if (PredictedContent is not null && PredictedContent.IsInnerCollectionDefined()) - { - writer.WriteStartObject(); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(InternalPredictionContentType.Content.ToString()); - writer.WritePropertyName("content"u8); - writer.WriteObjectValue(PredictedContent, options); - writer.WriteEndObject(); - } - else - { - writer.WriteNullValue(); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void DeserializePredictedContentValue(JsonProperty property, ref ChatMessageContent predictedContent) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - predictedContent = null; - } - else - { - foreach (JsonProperty predictionProperty in property.Value.EnumerateObject()) - { - if (predictionProperty.NameEquals("content"u8)) - { - ChatMessage.DeserializeContentValue(predictionProperty, ref predictedContent); - } - } - } - } } diff --git a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs index a2c61d520..b0136a2bc 100644 --- a/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs +++ b/.dotnet/src/Custom/Chat/ChatCompletionOptions.cs @@ -12,7 +12,6 @@ namespace OpenAI.Chat; [CodeGenSerialization(nameof(Messages), SerializationValueHook = nameof(SerializeMessagesValue))] [CodeGenSerialization(nameof(StopSequences), SerializationValueHook = nameof(SerializeStopSequencesValue), DeserializationValueHook = nameof(DeserializeStopSequencesValue))] [CodeGenSerialization(nameof(LogitBiases), SerializationValueHook = nameof(SerializeLogitBiasesValue), DeserializationValueHook = nameof(DeserializeLogitBiasesValue))] -[CodeGenSerialization(nameof(PredictedContent), SerializationValueHook = nameof(SerializePredictedContentValue), DeserializationValueHook = nameof(DeserializePredictedContentValue))] public partial class ChatCompletionOptions { // CUSTOM: @@ -221,6 +220,7 @@ public ChatAudioOptions AudioOptions } } + // CUSTOM: rename. [CodeGenMember("Prediction")] - public ChatMessageContent PredictedContent { get; set; } = new(); + public ChatOutputPrediction OutputPrediction { get; set; } } diff --git a/.dotnet/src/Custom/Chat/ChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/ChatMessage.Serialization.cs index 7124d94a0..b36120df9 100644 --- a/.dotnet/src/Custom/Chat/ChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatMessage.Serialization.cs @@ -7,7 +7,8 @@ namespace OpenAI.Chat; [CodeGenSuppress("global::System.ClientModel.Primitives.IJsonModel.Write", typeof(Utf8JsonWriter), typeof(ModelReaderWriterOptions))] -public partial class ChatMessage : IJsonModel +[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))] +public partial class ChatMessage { [MethodImpl(MethodImplOptions.AggressiveInlining)] internal void SerializeContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options = null) @@ -18,25 +19,7 @@ internal void SerializeContentValue(Utf8JsonWriter writer, ModelReaderWriterOpti [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void DeserializeContentValue(JsonProperty property, ref ChatMessageContent content, ModelReaderWriterOptions options = null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - return; - } - else if (property.Value.ValueKind == JsonValueKind.String) - { - content = new ChatMessageContent(property.Value.GetString()); - } - else if (property.Value.ValueKind == JsonValueKind.Array) - { - IList parts = []; - - foreach (var item in property.Value.EnumerateArray()) - { - parts.Add(ChatMessageContentPart.DeserializeChatMessageContentPart(item, options)); - } - - content = new ChatMessageContent(parts); - } + content = ChatMessageContent.DeserializeChatMessageContent(property.Value, options); } void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) diff --git a/.dotnet/src/Custom/Chat/ChatMessage.cs b/.dotnet/src/Custom/Chat/ChatMessage.cs index 9f165a510..08221dd2d 100644 --- a/.dotnet/src/Custom/Chat/ChatMessage.cs +++ b/.dotnet/src/Custom/Chat/ChatMessage.cs @@ -53,7 +53,6 @@ namespace OpenAI.Chat; /// /// [CodeGenModel("ChatCompletionRequestMessage")] -[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))] public partial class ChatMessage { /// diff --git a/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs b/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs new file mode 100644 index 000000000..edc1fc3ae --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs @@ -0,0 +1,50 @@ +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text.Json; + +namespace OpenAI.Chat; + +public partial class ChatMessageContent +{ + internal void WriteTo(Utf8JsonWriter writer, ModelReaderWriterOptions options = null) + { + if (Count == 0) + { + writer.WriteNullValue(); + } + else if (Count == 1 && this[0].Kind == ChatMessageContentPartKind.Text) + { + writer.WriteStringValue(this[0].Text); + } + else + { + writer.WriteStartArray(); + foreach (ChatMessageContentPart part in this) + { + writer.WriteObjectValue(part, options); + } + writer.WriteEndArray(); + } + } + + internal static ChatMessageContent DeserializeChatMessageContent(JsonElement element, ModelReaderWriterOptions options = null) + { + if (element.ValueKind == JsonValueKind.String) + { + return new(element.GetString()); + } + else if (element.ValueKind == JsonValueKind.Array) + { + List parts = []; + foreach (JsonElement contentPartElement in element.EnumerateArray()) + { + parts.Add(ChatMessageContentPart.DeserializeChatMessageContentPart(contentPartElement, options)); + } + return new(parts); + } + return new(); + } +} diff --git a/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs b/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs new file mode 100644 index 000000000..e1825c4e9 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Chat; + +[CodeGenModel("ChatOutputPrediction")] +public partial class ChatOutputPrediction +{ + // CUSTOM: Rename; add public visibility for derived type discriminator insight. + [CodeGenMember("Type")] + public ChatOutputPredictionKind Kind { get; } + + public static ChatOutputPrediction CreateStaticContentPrediction(IEnumerable contentParts) + => new InternalChatOutputPredictionContent(new ChatMessageContent(contentParts)); + + public static ChatOutputPrediction CreateStaticContentPrediction(string content) + => new InternalChatOutputPredictionContent([ChatMessageContentPart.CreateTextPart(content)]); +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/ChatOutputPredictionKind.cs b/.dotnet/src/Custom/Chat/ChatOutputPredictionKind.cs new file mode 100644 index 000000000..2cc902f30 --- /dev/null +++ b/.dotnet/src/Custom/Chat/ChatOutputPredictionKind.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Chat; + +[CodeGenModel("ChatOutputPredictionType")] +public readonly partial struct ChatOutputPredictionKind +{ + // CUSTOM: Rename for clarity. + [CodeGenMember("Content")] + public static ChatOutputPredictionKind StaticContent { get; } = new ChatOutputPredictionKind(ContentValue); +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs index 9170e26d8..3547f3a9a 100644 --- a/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Chat/Internal/GeneratorStubs.cs @@ -105,8 +105,5 @@ internal partial class InternalChatCompletionRequestMessageContentPartAudio { } [CodeGenModel("ChatCompletionRequestMessageContentPartAudioInputAudio")] internal partial class InternalChatCompletionRequestMessageContentPartAudioInputAudio { } -[CodeGenModel("PredictionContent")] -internal partial class InternalPredictionContent { } - -[CodeGenModel("PredictionContentType")] -internal readonly partial struct InternalPredictionContentType { } +[CodeGenModel("UnknownChatOutputPrediction")] +internal partial class InternalUnknownChatOutputPrediction { } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.Serialization.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.Serialization.cs index 28c03901f..9ed3a9c7b 100644 --- a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.Serialization.cs @@ -4,30 +4,16 @@ namespace OpenAI.Chat; -internal partial class InternalChatCompletionResponseMessage : IJsonModel +[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))] +internal partial class InternalChatCompletionResponseMessage { [MethodImpl(MethodImplOptions.AggressiveInlining)] private void SerializeContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - if (Content.Count > 0) - { - writer.WriteStringValue(Content[0].Text); - } - else - { - writer.WriteNullValue(); - } - } + => Content.WriteTo(writer, options); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void DeserializeContentValue(JsonProperty property, ref ChatMessageContent content, ModelReaderWriterOptions options = null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - // This is a collection property. We must return an empty collection instead of a null value. - content = new ChatMessageContent(); - return; - } - content = new ChatMessageContent(property.Value.GetString()); + content = ChatMessageContent.DeserializeChatMessageContent(property.Value, options); } } diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.cs index c8aadb21f..607a63c74 100644 --- a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.cs +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.cs @@ -5,7 +5,6 @@ namespace OpenAI.Chat; [CodeGenModel("ChatCompletionResponseMessage")] [CodeGenSuppress("InternalChatCompletionResponseMessage", typeof(IEnumerable))] -[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))] internal partial class InternalChatCompletionResponseMessage { // CUSTOM: Changed type from InternalChatCompletionResponseMessageRole. diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.Serialization.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.Serialization.cs index 186ff1128..4e0758f3d 100644 --- a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.Serialization.cs +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.Serialization.cs @@ -4,30 +4,16 @@ namespace OpenAI.Chat; -internal partial class InternalChatCompletionStreamResponseDelta : IJsonModel +[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))] +internal partial class InternalChatCompletionStreamResponseDelta { [MethodImpl(MethodImplOptions.AggressiveInlining)] private void SerializeContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - if (Content.Count > 0) - { - writer.WriteStringValue(Content[0].Text); - } - else - { - writer.WriteNullValue(); - } - } + => Content.WriteTo(writer, options); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void DeserializeContentValue(JsonProperty property, ref ChatMessageContent content, ModelReaderWriterOptions options = null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - // This is a collection property. We must return an empty collection instead of a null value. - content = new ChatMessageContent(); - return; - } - content = new ChatMessageContent(property.Value.ToString()); + content = ChatMessageContent.DeserializeChatMessageContent(property.Value, options); } } diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs index 80c111996..1b7c58d68 100644 --- a/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatCompletionStreamResponseDelta.cs @@ -4,7 +4,6 @@ namespace OpenAI.Chat; [CodeGenModel("ChatCompletionStreamResponseDelta")] [CodeGenSuppress("InternalChatCompletionStreamResponseDelta")] -[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))] internal partial class InternalChatCompletionStreamResponseDelta { // CUSTOM: Changed type from string. diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionContent.Serialization.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionContent.Serialization.cs new file mode 100644 index 000000000..a7a0933ec --- /dev/null +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionContent.Serialization.cs @@ -0,0 +1,22 @@ +using System.ClientModel.Primitives; +using System.Data; +using System.Text.Json; +using System; +using System.Collections; +using System.Runtime.CompilerServices; + +namespace OpenAI.Chat; + +[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))] +internal partial class InternalChatOutputPredictionContent +{ + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void SerializeContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options = null) + => Content.WriteTo(writer, options); + + private static void DeserializeContentValue(JsonProperty property, ref ChatMessageContent content) + { + content = ChatMessageContent.DeserializeChatMessageContent(property.Value); + } +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionContent.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionContent.cs new file mode 100644 index 000000000..a3d643a9b --- /dev/null +++ b/.dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionContent.cs @@ -0,0 +1,15 @@ +using System.ClientModel.Primitives; +using System.Data; +using System.Text.Json; +using System; +using System.Collections; + +namespace OpenAI.Chat; + +[CodeGenModel("ChatOutputPredictionContent")] +internal partial class InternalChatOutputPredictionContent +{ + // CUSTOM: Assign type to a collection of content parts + [CodeGenMember("Content")] + public ChatMessageContent Content { get; set; } = new(); +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/InternalPredictionContent.cs b/.dotnet/src/Custom/Chat/InternalPredictionContent.cs new file mode 100644 index 000000000..26427685f --- /dev/null +++ b/.dotnet/src/Custom/Chat/InternalPredictionContent.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI.Chat; + +// CUSTOM: Added base type. + +[CodeGenModel("PredictionContent")] +internal partial class InternalPredictionContent : ChatOutputPrediction +{ + +} \ No newline at end of file diff --git a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs index 49abeec67..64308c959 100644 --- a/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatCompletionOptions.Serialization.cs @@ -283,13 +283,12 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("reasoning_effort"u8); writer.WriteStringValue(ReasoningEffortLevel.Value.ToString()); } - // CUSTOM: Check inner collection is defined. - if (Optional.IsDefined(PredictedContent) && PredictedContent.IsInnerCollectionDefined() && _additionalBinaryDataProperties?.ContainsKey("prediction") != true) + if (Optional.IsDefined(OutputPrediction) && _additionalBinaryDataProperties?.ContainsKey("prediction") != true) { - if (PredictedContent != null) + if (OutputPrediction != null) { writer.WritePropertyName("prediction"u8); - this.SerializePredictedContentValue(writer, options); + writer.WriteObjectValue(OutputPrediction, options); } else { @@ -403,7 +402,7 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme IDictionary metadata = default; bool? storedOutputEnabled = default; ChatReasoningEffortLevel? reasoningEffortLevel = default; - ChatMessageContent predictedContent = default; + ChatOutputPrediction outputPrediction = default; InternalCreateChatCompletionRequestServiceTier? serviceTier = default; IList internalModalities = default; ChatAudioOptions audioOptions = default; @@ -666,7 +665,12 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme } if (prop.NameEquals("prediction"u8)) { - DeserializePredictedContentValue(prop, ref predictedContent); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + outputPrediction = null; + continue; + } + outputPrediction = ChatOutputPrediction.DeserializeChatOutputPrediction(prop.Value, options); continue; } if (prop.NameEquals("service_tier"u8)) @@ -735,7 +739,7 @@ internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonEleme metadata ?? new ChangeTrackingDictionary(), storedOutputEnabled, reasoningEffortLevel, - predictedContent, + outputPrediction, serviceTier, internalModalities, audioOptions, diff --git a/.dotnet/src/Generated/Models/ChatCompletionOptions.cs b/.dotnet/src/Generated/Models/ChatCompletionOptions.cs index a5e82ba26..5dd47d2c0 100644 --- a/.dotnet/src/Generated/Models/ChatCompletionOptions.cs +++ b/.dotnet/src/Generated/Models/ChatCompletionOptions.cs @@ -11,7 +11,7 @@ public partial class ChatCompletionOptions { private protected IDictionary _additionalBinaryDataProperties; - internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, ChatResponseFormat responseFormat, float? temperature, float? topP, IList tools, IList messages, InternalCreateChatCompletionRequestModel model, int? n, bool? stream, InternalChatCompletionStreamOptions streamOptions, bool? includeLogProbabilities, int? topLogProbabilityCount, IList stopSequences, IDictionary logitBiases, ChatToolChoice toolChoice, ChatFunctionChoice functionChoice, bool? allowParallelToolCalls, string endUserId, long? seed, int? deprecatedMaxTokens, int? maxOutputTokenCount, IList functions, IDictionary metadata, bool? storedOutputEnabled, ChatReasoningEffortLevel? reasoningEffortLevel, ChatMessageContent predictedContent, InternalCreateChatCompletionRequestServiceTier? serviceTier, IList internalModalities, ChatAudioOptions audioOptions, IDictionary additionalBinaryDataProperties) + internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, ChatResponseFormat responseFormat, float? temperature, float? topP, IList tools, IList messages, InternalCreateChatCompletionRequestModel model, int? n, bool? stream, InternalChatCompletionStreamOptions streamOptions, bool? includeLogProbabilities, int? topLogProbabilityCount, IList stopSequences, IDictionary logitBiases, ChatToolChoice toolChoice, ChatFunctionChoice functionChoice, bool? allowParallelToolCalls, string endUserId, long? seed, int? deprecatedMaxTokens, int? maxOutputTokenCount, IList functions, IDictionary metadata, bool? storedOutputEnabled, ChatReasoningEffortLevel? reasoningEffortLevel, ChatOutputPrediction outputPrediction, InternalCreateChatCompletionRequestServiceTier? serviceTier, IList internalModalities, ChatAudioOptions audioOptions, IDictionary additionalBinaryDataProperties) { FrequencyPenalty = frequencyPenalty; PresencePenalty = presencePenalty; @@ -39,7 +39,7 @@ internal ChatCompletionOptions(float? frequencyPenalty, float? presencePenalty, Metadata = metadata; StoredOutputEnabled = storedOutputEnabled; ReasoningEffortLevel = reasoningEffortLevel; - PredictedContent = predictedContent; + OutputPrediction = outputPrediction; _serviceTier = serviceTier; _internalModalities = internalModalities; _audioOptions = audioOptions; diff --git a/.dotnet/src/Generated/Models/ChatOutputPrediction.Serialization.cs b/.dotnet/src/Generated/Models/ChatOutputPrediction.Serialization.cs new file mode 100644 index 000000000..09cc097e1 --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatOutputPrediction.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + [PersistableModelProxy(typeof(InternalUnknownChatOutputPrediction))] + public partial class ChatOutputPrediction : IJsonModel + { + internal ChatOutputPrediction() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatOutputPrediction)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Kind.ToString()); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChatOutputPrediction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual ChatOutputPrediction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatOutputPrediction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatOutputPrediction(document.RootElement, options); + } + + internal static ChatOutputPrediction DeserializeChatOutputPrediction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "content": + return InternalChatOutputPredictionContent.DeserializeInternalChatOutputPredictionContent(element, options); + } + } + return InternalUnknownChatOutputPrediction.DeserializeInternalUnknownChatOutputPrediction(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatOutputPrediction)} does not support writing '{options.Format}' format."); + } + } + + ChatOutputPrediction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual ChatOutputPrediction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeChatOutputPrediction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatOutputPrediction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(ChatOutputPrediction chatOutputPrediction) + { + if (chatOutputPrediction == null) + { + return null; + } + return BinaryContent.Create(chatOutputPrediction, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator ChatOutputPrediction(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeChatOutputPrediction(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/ChatOutputPrediction.cs b/.dotnet/src/Generated/Models/ChatOutputPrediction.cs new file mode 100644 index 000000000..b16c0970e --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatOutputPrediction.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Chat +{ + public partial class ChatOutputPrediction + { + private protected IDictionary _additionalBinaryDataProperties; + + private protected ChatOutputPrediction(ChatOutputPredictionKind kind) + { + Kind = kind; + } + + internal ChatOutputPrediction(ChatOutputPredictionKind kind, IDictionary additionalBinaryDataProperties) + { + Kind = kind; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/ChatOutputPredictionKind.cs b/.dotnet/src/Generated/Models/ChatOutputPredictionKind.cs new file mode 100644 index 000000000..fcff96daa --- /dev/null +++ b/.dotnet/src/Generated/Models/ChatOutputPredictionKind.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + public readonly partial struct ChatOutputPredictionKind : IEquatable + { + private readonly string _value; + private const string ContentValue = "content"; + + public ChatOutputPredictionKind(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static bool operator ==(ChatOutputPredictionKind left, ChatOutputPredictionKind right) => left.Equals(right); + + public static bool operator !=(ChatOutputPredictionKind left, ChatOutputPredictionKind right) => !left.Equals(right); + + public static implicit operator ChatOutputPredictionKind(string value) => new ChatOutputPredictionKind(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatOutputPredictionKind other && Equals(other); + + public bool Equals(ChatOutputPredictionKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.Serialization.cs new file mode 100644 index 000000000..fdf1443cc --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.Serialization.cs @@ -0,0 +1,134 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatOutputPredictionContent : IJsonModel + { + internal InternalChatOutputPredictionContent() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatOutputPredictionContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + // CUSTOM: Check inner collection is defined. + if (Content.IsInnerCollectionDefined() && _additionalBinaryDataProperties?.ContainsKey("content") != true) + { + writer.WritePropertyName("content"u8); + this.SerializeContentValue(writer, options); + } + } + + InternalChatOutputPredictionContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalChatOutputPredictionContent)JsonModelCreateCore(ref reader, options); + + protected override ChatOutputPrediction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalChatOutputPredictionContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatOutputPredictionContent(document.RootElement, options); + } + + internal static InternalChatOutputPredictionContent DeserializeInternalChatOutputPredictionContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ChatOutputPredictionKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ChatMessageContent content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + kind = new ChatOutputPredictionKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + DeserializeContentValue(prop, ref content); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalChatOutputPredictionContent(kind, additionalBinaryDataProperties, content); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatOutputPredictionContent)} does not support writing '{options.Format}' format."); + } + } + + InternalChatOutputPredictionContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalChatOutputPredictionContent)PersistableModelCreateCore(data, options); + + protected override ChatOutputPrediction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalChatOutputPredictionContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatOutputPredictionContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalChatOutputPredictionContent internalChatOutputPredictionContent) + { + if (internalChatOutputPredictionContent == null) + { + return null; + } + return BinaryContent.Create(internalChatOutputPredictionContent, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalChatOutputPredictionContent(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatOutputPredictionContent(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.cs b/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.cs new file mode 100644 index 000000000..e927b3799 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalChatOutputPredictionContent : ChatOutputPrediction + { + public InternalChatOutputPredictionContent(ChatMessageContent content) : base(ChatOutputPredictionKind.StaticContent) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + internal InternalChatOutputPredictionContent(ChatOutputPredictionKind kind, IDictionary additionalBinaryDataProperties, ChatMessageContent content) : base(kind, additionalBinaryDataProperties) + { + Content = content; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalPredictionContent.Serialization.cs b/.dotnet/src/Generated/Models/InternalPredictionContent.Serialization.cs deleted file mode 100644 index b79bfe6cc..000000000 --- a/.dotnet/src/Generated/Models/InternalPredictionContent.Serialization.cs +++ /dev/null @@ -1,163 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI; - -namespace OpenAI.Chat -{ - internal partial class InternalPredictionContent : IJsonModel - { - internal InternalPredictionContent() - { - } - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalPredictionContent)} does not support writing '{format}' format."); - } - if (_additionalBinaryDataProperties?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - } - if (_additionalBinaryDataProperties?.ContainsKey("content") != true) - { - writer.WritePropertyName("content"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Content); -#else - using (JsonDocument document = JsonDocument.Parse(Content)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (true && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - InternalPredictionContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - protected virtual InternalPredictionContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalPredictionContent)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalPredictionContent(document.RootElement, options); - } - - internal static InternalPredictionContent DeserializeInternalPredictionContent(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalPredictionContentType @type = default; - BinaryData content = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("type"u8)) - { - @type = new InternalPredictionContentType(prop.Value.GetString()); - continue; - } - if (prop.NameEquals("content"u8)) - { - content = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (true) - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new InternalPredictionContent(@type, content, additionalBinaryDataProperties); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalPredictionContent)} does not support writing '{options.Format}' format."); - } - } - - InternalPredictionContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - protected virtual InternalPredictionContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data)) - { - return DeserializeInternalPredictionContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalPredictionContent)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - public static implicit operator BinaryContent(InternalPredictionContent internalPredictionContent) - { - if (internalPredictionContent == null) - { - return null; - } - return BinaryContent.Create(internalPredictionContent, ModelSerializationExtensions.WireOptions); - } - - public static explicit operator InternalPredictionContent(ClientResult result) - { - using PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content); - return DeserializeInternalPredictionContent(document.RootElement, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet/src/Generated/Models/InternalPredictionContent.cs b/.dotnet/src/Generated/Models/InternalPredictionContent.cs deleted file mode 100644 index 7277296b3..000000000 --- a/.dotnet/src/Generated/Models/InternalPredictionContent.cs +++ /dev/null @@ -1,39 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using OpenAI; - -namespace OpenAI.Chat -{ - internal partial class InternalPredictionContent - { - private protected IDictionary _additionalBinaryDataProperties; - - public InternalPredictionContent(BinaryData content) - { - Argument.AssertNotNull(content, nameof(content)); - - Content = content; - } - - internal InternalPredictionContent(InternalPredictionContentType @type, BinaryData content, IDictionary additionalBinaryDataProperties) - { - Type = @type; - Content = content; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - public InternalPredictionContentType Type { get; } = "content"; - - public BinaryData Content { get; } - - internal IDictionary SerializedAdditionalRawData - { - get => _additionalBinaryDataProperties; - set => _additionalBinaryDataProperties = value; - } - } -} diff --git a/.dotnet/src/Generated/Models/InternalPredictionContentType.cs b/.dotnet/src/Generated/Models/InternalPredictionContentType.cs deleted file mode 100644 index ea67f9935..000000000 --- a/.dotnet/src/Generated/Models/InternalPredictionContentType.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Chat -{ - internal readonly partial struct InternalPredictionContentType : IEquatable - { - private readonly string _value; - private const string ContentValue = "content"; - - public InternalPredictionContentType(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static InternalPredictionContentType Content { get; } = new InternalPredictionContentType(ContentValue); - - public static bool operator ==(InternalPredictionContentType left, InternalPredictionContentType right) => left.Equals(right); - - public static bool operator !=(InternalPredictionContentType left, InternalPredictionContentType right) => !left.Equals(right); - - public static implicit operator InternalPredictionContentType(string value) => new InternalPredictionContentType(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalPredictionContentType other && Equals(other); - - public bool Equals(InternalPredictionContentType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.Serialization.cs b/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.Serialization.cs new file mode 100644 index 000000000..2bdf952c1 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.Serialization.cs @@ -0,0 +1,105 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Chat +{ + internal partial class InternalUnknownChatOutputPrediction : IJsonModel + { + internal InternalUnknownChatOutputPrediction() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatOutputPrediction)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + ChatOutputPrediction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected override ChatOutputPrediction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatOutputPrediction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatOutputPrediction(document.RootElement, options); + } + + internal static InternalUnknownChatOutputPrediction DeserializeInternalUnknownChatOutputPrediction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ChatOutputPredictionKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + kind = new ChatOutputPredictionKind(prop.Value.GetString()); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalUnknownChatOutputPrediction(kind, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatOutputPrediction)} does not support writing '{options.Format}' format."); + } + } + + ChatOutputPrediction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected override ChatOutputPrediction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeChatOutputPrediction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatOutputPrediction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.cs b/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.cs new file mode 100644 index 000000000..a65d8f269 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI.Chat +{ + internal partial class InternalUnknownChatOutputPrediction : ChatOutputPrediction + { + internal InternalUnknownChatOutputPrediction(ChatOutputPredictionKind kind, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index b7da06559..c859314a4 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -919,7 +919,7 @@ public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTok return new ChatInputTokenUsageDetails(audioTokenCount, cachedTokenCount, additionalBinaryDataProperties: null); } - public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalty = default, float? presencePenalty = default, ChatResponseFormat responseFormat = default, float? temperature = default, float? topP = default, IEnumerable tools = default, IEnumerable messages = default, InternalCreateChatCompletionRequestModel model = default, int? n = default, bool? stream = default, InternalChatCompletionStreamOptions streamOptions = default, bool? includeLogProbabilities = default, int? topLogProbabilityCount = default, IEnumerable stopSequences = default, IDictionary logitBiases = default, ChatToolChoice toolChoice = default, ChatFunctionChoice functionChoice = default, bool? allowParallelToolCalls = default, string endUserId = default, long? seed = default, int? deprecatedMaxTokens = default, int? maxOutputTokenCount = default, IEnumerable functions = default, IDictionary metadata = default, bool? storedOutputEnabled = default, ChatReasoningEffortLevel? reasoningEffortLevel = default, ChatMessageContent predictedContent = default, InternalCreateChatCompletionRequestServiceTier? serviceTier = default, IEnumerable internalModalities = default, ChatAudioOptions audioOptions = default) + public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalty = default, float? presencePenalty = default, ChatResponseFormat responseFormat = default, float? temperature = default, float? topP = default, IEnumerable tools = default, IEnumerable messages = default, InternalCreateChatCompletionRequestModel model = default, int? n = default, bool? stream = default, InternalChatCompletionStreamOptions streamOptions = default, bool? includeLogProbabilities = default, int? topLogProbabilityCount = default, IEnumerable stopSequences = default, IDictionary logitBiases = default, ChatToolChoice toolChoice = default, ChatFunctionChoice functionChoice = default, bool? allowParallelToolCalls = default, string endUserId = default, long? seed = default, int? deprecatedMaxTokens = default, int? maxOutputTokenCount = default, IEnumerable functions = default, IDictionary metadata = default, bool? storedOutputEnabled = default, ChatReasoningEffortLevel? reasoningEffortLevel = default, ChatOutputPrediction outputPrediction = default, InternalCreateChatCompletionRequestServiceTier? serviceTier = default, IEnumerable internalModalities = default, ChatAudioOptions audioOptions = default) { tools ??= new ChangeTrackingList(); messages ??= new ChangeTrackingList(); @@ -956,7 +956,7 @@ public static ChatCompletionOptions ChatCompletionOptions(float? frequencyPenalt metadata, storedOutputEnabled, reasoningEffortLevel, - predictedContent, + outputPrediction, serviceTier, internalModalities?.ToList(), audioOptions, @@ -1032,6 +1032,12 @@ public static FunctionChatMessage FunctionChatMessage(ChatMessageContent content return new FunctionChatMessage(content, Chat.ChatMessageRole.Function, additionalBinaryDataProperties: null, functionName); } + public static ChatOutputPrediction ChatOutputPrediction(string kind = default) + { + + return new InternalUnknownChatOutputPrediction(new ChatOutputPredictionKind(kind), additionalBinaryDataProperties: null); + } + public static ChatAudioOptions ChatAudioOptions(ChatOutputAudioVoice outputAudioVoice = default, ChatOutputAudioFormat outputAudioFormat = default) { diff --git a/.dotnet/tests/Chat/ChatSmokeTests.cs b/.dotnet/tests/Chat/ChatSmokeTests.cs index fc9c1f88b..9aea729aa 100644 --- a/.dotnet/tests/Chat/ChatSmokeTests.cs +++ b/.dotnet/tests/Chat/ChatSmokeTests.cs @@ -913,7 +913,6 @@ public void CanUseCollections() ChatCompletionOptions options = new(); Assert.That(options.Tools.Count, Is.EqualTo(0)); Assert.That(options.Metadata.Count, Is.EqualTo(0)); - Assert.That(options.PredictedContent.Count, Is.EqualTo(0)); Assert.That(options.StopSequences.Count, Is.EqualTo(0)); } } diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index d66ccd531..47bc369a2 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -895,21 +895,43 @@ public async Task PredictedOutputsWork() { ChatClient client = GetTestClient(TestScenario.Chat); - ChatCompletionOptions options = new() - { - PredictedContent = + foreach (ChatOutputPrediction predictionVariant in new List( [ - ChatMessageContentPart.CreateTextPart(""" - { - "feature_name": "test_feature", - "enabled": true - } - """.ReplaceLineEndings("\n")), - ], - }; + // Plain string + ChatOutputPrediction.CreateStaticContentPrediction(""" + { + "feature_name": "test_feature", + "enabled": true + } + """.ReplaceLineEndings("\n")), + // One content part + ChatOutputPrediction.CreateStaticContentPrediction( + [ + ChatMessageContentPart.CreateTextPart(""" + { + "feature_name": "test_feature", + "enabled": true + } + """.ReplaceLineEndings("\n")), + ]), + // Several content parts + ChatOutputPrediction.CreateStaticContentPrediction( + [ + "{\n", + " \"feature_name\": \"test_feature\",\n", + " \"enabled\": true\n", + "}", + ]), + ])) + { + ChatCompletionOptions options = new() + { + OutputPrediction = predictionVariant, + }; + Assert.That(options.OutputPrediction.Kind, Is.EqualTo(ChatOutputPredictionKind.StaticContent)); - ChatMessage message = ChatMessage.CreateUserMessage(""" - Modify the following input to enable the feature. Only respond with the JSON and include no other text. + ChatMessage message = ChatMessage.CreateUserMessage(""" + Modify the following input to enable the feature. Only respond with the JSON and include no other text. Do not enclose in markdown backticks or any other additional annotations. { "feature_name": "test_feature", @@ -917,9 +939,10 @@ Modify the following input to enable the feature. Only respond with the JSON and } """.ReplaceLineEndings("\n")); - ChatCompletion completion = await client.CompleteChatAsync([message], options); + ChatCompletion completion = await client.CompleteChatAsync([message], options); - Assert.That(completion.Usage.OutputTokenDetails.AcceptedPredictionTokenCount, Is.GreaterThan(0)); + Assert.That(completion.Usage.OutputTokenDetails.AcceptedPredictionTokenCount, Is.GreaterThan(0)); + } } [Test] diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index 18ceb4b8f..12550a147 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -4539,6 +4539,51 @@ components: type: object ChatMessageContentPart: type: object + ChatOutputPrediction: + type: object + required: + - type + properties: + type: + anyOf: + - type: string + - type: string + enum: + - content + discriminator: + propertyName: type + mapping: + content: '#/components/schemas/ChatOutputPredictionContent' + description: Base representation of predicted output from a model. + ChatOutputPredictionContent: + type: object + required: + - type + - content + properties: + type: + type: string + enum: + - content + description: |- + The type of the predicted content you want to provide. This type is + currently always `content`. + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' + description: |- + The content that should be matched when generating a model response. + If generated tokens would match this content, the entire model response + can be returned much more quickly. + x-oaiExpandable: true + allOf: + - $ref: '#/components/schemas/ChatOutputPrediction' + description: |- + Static predicted output content, such as the content of a text file that is + being regenerated. ChatResponseFormat: type: object required: @@ -5058,7 +5103,7 @@ components: prediction: type: object allOf: - - $ref: '#/components/schemas/PredictionContent' + - $ref: '#/components/schemas/ChatOutputPrediction' nullable: true description: |- Configuration for a [Predicted Output](/docs/guides/predicted-outputs), @@ -9298,33 +9343,6 @@ components: ParallelToolCalls: type: boolean description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - PredictionContent: - type: object - required: - - type - - content - properties: - type: - type: string - enum: - - content - description: |- - The type of the predicted content you want to provide. This type is - currently always `content`. - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' - description: |- - The content that should be matched when generating a model response. - If generated tokens would match this content, the entire model response - can be returned much more quickly. - x-oaiExpandable: true - description: |- - Static predicted output content, such as the content of a text file that is - being regenerated. Project: type: object required: diff --git a/.scripts/Edit-Serialization.ps1 b/.scripts/Edit-Serialization.ps1 index e72f40ff2..29dc2a8e9 100644 --- a/.scripts/Edit-Serialization.ps1 +++ b/.scripts/Edit-Serialization.ps1 @@ -196,13 +196,13 @@ Update-In-File-With-Retry ` -RequirePresence Update-In-File-With-Retry ` - -FilePath "$directory\ChatCompletionOptions.Serialization.cs" ` + -FilePath "$directory\InternalChatOutputPredictionContent.Serialization.cs" ` -SearchPatternLines @( - "if \(Optional\.IsDefined\(PredictedContent\) && _additionalBinaryDataProperties\?\.ContainsKey\(`"prediction`"\) != true\)" + "if \(_additionalBinaryDataProperties\?\.ContainsKey\(`"content`"\) != true\)" ) ` -ReplacePatternLines @( "// CUSTOM: Check inner collection is defined." - "if (Optional.IsDefined(PredictedContent) && PredictedContent.IsInnerCollectionDefined() && _additionalBinaryDataProperties?.ContainsKey(`"prediction`") != true)" + "if (Content.IsInnerCollectionDefined() && _additionalBinaryDataProperties?.ContainsKey(`"content`") != true)" ) ` -OutputIndentation 12 ` -RequirePresence diff --git a/.scripts/Remove-Abstract.ps1 b/.scripts/Remove-Abstract.ps1 index b54551d33..a6cda71e7 100644 --- a/.scripts/Remove-Abstract.ps1 +++ b/.scripts/Remove-Abstract.ps1 @@ -7,7 +7,9 @@ $targetFilenames = ( "ChatMessage.cs", "ChatMessage.Serialization.cs", "ChatResponseFormat.cs", - "ChatResponseFormat.Serialization.cs" + "ChatResponseFormat.Serialization.cs", + "ChatOutputPrediction.cs", + "ChatOutputPrediction.Serialization.cs" ) foreach ($targetFilename in $targetFilenames) { diff --git a/.typespec/chat/custom.tsp b/.typespec/chat/custom.tsp index ea6cc0684..f86e0bd19 100644 --- a/.typespec/chat/custom.tsp +++ b/.typespec/chat/custom.tsp @@ -22,6 +22,14 @@ model ChatResponseFormatJsonSchema extends ChatResponseFormat { ...ResponseFormatJsonSchema; } +/** + * Base representation of predicted output from a model. + */ +@discriminator("type") +model ChatOutputPrediction { + type: string | "content"; +} + model ChatCompletionFunctionChoice {} model ChatCompletionToolChoice {} diff --git a/.typespec/chat/models.tsp b/.typespec/chat/models.tsp index 7354fb0b9..0bb6bd09d 100644 --- a/.typespec/chat/models.tsp +++ b/.typespec/chat/models.tsp @@ -243,6 +243,7 @@ model CreateChatCompletionRequest { modalities?: ChatCompletionModalities | null; + // Tool customization: Apply an implied base discriminated type to 'prediction' /** * Configuration for a [Predicted Output](/docs/guides/predicted-outputs), * which can greatly improve response times when large parts of the model @@ -250,7 +251,7 @@ model CreateChatCompletionRequest { * regenerating a file with only minor changes to most of the content. */ @extension("x-oaiExpandable", true) - prediction?: PredictionContent | null; + prediction?: ChatOutputPrediction | null; @doc(""" Parameters for audio output. Required when audio output is requested with @@ -956,11 +957,12 @@ model CreateChatCompletionStreamResponse { /** Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ alias CreateChatCompletionImageResponse = unknown; +// Tool customization: Apply an implied base discriminated type to 'prediction' /** * Static predicted output content, such as the content of a text file that is * being regenerated. */ -model PredictionContent { +model ChatOutputPredictionContent extends ChatOutputPrediction { @doc(""" The type of the predicted content you want to provide. This type is currently always `content`. diff --git a/README.md b/README.md index 1039d52af..de2d4b823 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Date: Fri Jan 31 21:29:23 2025 +0000 Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk ``` -commit 8b8856f854f166b9dbb80f60bf2d9f5ca8830f2f (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) +commit 4e2e95153f2e504245a014ec1f27229d39f0529f (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) Author: Travis Wilson -Date: Fri Jan 31 16:47:07 2025 -0800 +Date: Mon Feb 3 18:29:01 2025 -0800 ``` There are some deltas: From 299c78335e1006aa0b24f020a014039f22360cab Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Mon, 3 Feb 2025 18:48:57 -0800 Subject: [PATCH 37/44] merge predicted output change and rename to SourceIP --- .../sdk/openai/Azure.AI.OpenAI/CHANGELOG.md | 2 +- .../sdk/openai/Azure.AI.OpenAI/assets.json | 2 +- .../src/Custom/Chat/UserSecurityContext.cs | 3 +- .../UserSecurityContext.Serialization.cs | 4 +- .../src/Generated/UserSecurityContext.cs | 6 +- .../openai/Azure.AI.OpenAI/tests/ChatTests.cs | 59 ++++++++++----- ...e-openai-2025-01-01-preview-generated.yaml | 74 ++++++++++++------- 7 files changed, 96 insertions(+), 54 deletions(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md index 6d4a09fbd..7cf0bd4f0 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/CHANGELOG.md @@ -7,7 +7,7 @@ This preview release aligns with the corresponding `2.2.0` beta of `OpenAI` and New features include since 2.1.0-beta.2 include: - Audio input for Chat Completions using `gpt-4o-audio-preview` or other compatible models: provide input audio via `ChatMessageContentPart.CreateInputAudioPart()`, set `AudioOptions` and `ResponseModalities` on `ChatCompletionOptions`, retrieve response audio via `OutputAudio` on `ChatCompletion`, and reference audio history from the assistant by using the `AssistantChatMessage(ChatCompletion)` constructor or using `ChatMessageContentPart.CreateAudioPart(string)`. For more information, refer to the examples in [the OpenAI README](https://github.com/openai/openai-dotnet/blob/main/README.md). -- Predicted outputs in Chat Completions: `ChatCompletionOptions` accepts a distinct `PredictedContent` collection (only text items) that can be used to optimize completion efficiency for scenarios like code completion. For more information, see [OpenAI's predicted outputs announcement](https://community.openai.com/t/introducing-predicted-outputs/1004502). +- Predicted outputs in Chat Completions: `ChatCompletionOptions` accepts an `OutputPrediction` property that can be used via `ChatOutputPrediction.CreateStaticContentPrediction()` with text content to optimize operation efficiency for scenarios like code completion. For more information, see [OpenAI's predicted outputs announcement](https://community.openai.com/t/introducing-predicted-outputs/1004502). - Chat Completions `o`-series model feature support: the new `developer` message role via `DeveloperChatMessage` (used just like `SystemChatMessage`), `ReasoningEffortLevel` on Chat Completion options - [AOAI exclusive] `UserSecurityContext` integration with [Defender for Cloud](https://learn.microsoft.com/azure/defender-for-cloud/gain-end-user-context-ai); add a `UserSecurityContext` instance to `ChatCompletionOptions` with `SetUserSecurityContext()` diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json index 5d8915c07..f602fdfae 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "dotnet.azure/openai/Azure.AI.OpenAI", - "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_be978e5b29" + "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_1e5ebe7b60" } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs index c657ba7b2..196fe7fea 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs @@ -19,5 +19,6 @@ public partial class UserSecurityContext /// The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. public string EndUserTenantId { get; set; } /// Captures the original client's IP address. - public string SourceIp { get; set; } + [CodeGenMember("SourceIp")] + public string SourceIP { get; set; } } \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.Serialization.cs index 053a1082f..ce8fcb983 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.Serialization.cs @@ -44,10 +44,10 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("end_user_tenant_id"u8); writer.WriteStringValue(EndUserTenantId); } - if (SerializedAdditionalRawData?.ContainsKey("source_ip") != true && Optional.IsDefined(SourceIp)) + if (SerializedAdditionalRawData?.ContainsKey("source_ip") != true && Optional.IsDefined(SourceIP)) { writer.WritePropertyName("source_ip"u8); - writer.WriteStringValue(SourceIp); + writer.WriteStringValue(SourceIP); } if (SerializedAdditionalRawData != null) { diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs index 0b5329731..5d38a1d50 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs @@ -50,14 +50,14 @@ internal UserSecurityContext() /// The name of the application. Sensitive personal information should not be included in this field. /// This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. /// The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. - /// Captures the original client's IP address. + /// Captures the original client's IP address. /// Keeps track of any properties unknown to the library. - internal UserSecurityContext(string applicationName, string endUserId, string endUserTenantId, string sourceIp, IDictionary serializedAdditionalRawData) + internal UserSecurityContext(string applicationName, string endUserId, string endUserTenantId, string sourceIP, IDictionary serializedAdditionalRawData) { ApplicationName = applicationName; EndUserId = endUserId; EndUserTenantId = endUserTenantId; - SourceIp = sourceIp; + SourceIP = sourceIP; SerializedAdditionalRawData = serializedAdditionalRawData; } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs index 480095487..ba94cb65f 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs @@ -523,11 +523,11 @@ public async Task UserSecurityContextWorks() ChatClient client = GetTestClient(); string userId = Guid.NewGuid().ToString(); - string sourceIp = "123.456.78.9"; + string sourceIP = "123.456.78.9"; UserSecurityContext userSecurityContext = new() { EndUserId = userId, - SourceIp = sourceIp, + SourceIP = sourceIP, }; ChatCompletionOptions options = new(); @@ -536,7 +536,7 @@ public async Task UserSecurityContextWorks() UserSecurityContext retrievedUserSecurityContext = options.GetUserSecurityContext(); Assert.That(retrievedUserSecurityContext, Is.Not.Null); Assert.That(retrievedUserSecurityContext.EndUserId, Is.EqualTo(userId)); - Assert.That(retrievedUserSecurityContext.SourceIp, Is.EqualTo(sourceIp)); + Assert.That(retrievedUserSecurityContext.SourceIP, Is.EqualTo(sourceIP)); ChatCompletion completion = await client.CompleteChatAsync([ChatMessage.CreateUserMessage("Hello, world!")]); Assert.That(completion, Is.Not.Null); @@ -750,21 +750,43 @@ public async Task PredictedOutputsWork() { ChatClient client = GetTestClient(); - ChatCompletionOptions options = new() - { - PredictedContent = + foreach (ChatOutputPrediction predictionVariant in new List( [ - ChatMessageContentPart.CreateTextPart(""" - { - "feature_name": "test_feature", - "enabled": true - } - """.ReplaceLineEndings("\n")), - ], - }; + // Plain string + ChatOutputPrediction.CreateStaticContentPrediction(""" + { + "feature_name": "test_feature", + "enabled": true + } + """.ReplaceLineEndings("\n")), + // One content part + ChatOutputPrediction.CreateStaticContentPrediction( + [ + ChatMessageContentPart.CreateTextPart(""" + { + "feature_name": "test_feature", + "enabled": true + } + """.ReplaceLineEndings("\n")), + ]), + // Several content parts + ChatOutputPrediction.CreateStaticContentPrediction( + [ + "{\n", + " \"feature_name\": \"test_feature\",\n", + " \"enabled\": true\n", + "}", + ]), + ])) + { + ChatCompletionOptions options = new() + { + OutputPrediction = predictionVariant, + }; + Assert.That(options.OutputPrediction.Kind, Is.EqualTo(ChatOutputPredictionKind.StaticContent)); - ChatMessage message = ChatMessage.CreateUserMessage(""" - Modify the following input to enable the feature. Only respond with the JSON and include no other text. Do not enclose in markdown backticks or any other syntax; just provide the JSON object. + ChatMessage message = ChatMessage.CreateUserMessage(""" + Modify the following input to enable the feature. Only respond with the JSON and include no other text. Do not enclose in markdown backticks or any other additional annotations. { "feature_name": "test_feature", @@ -772,9 +794,10 @@ public async Task PredictedOutputsWork() } """.ReplaceLineEndings("\n")); - ChatCompletion completion = await client.CompleteChatAsync([message], options); + ChatCompletion completion = await client.CompleteChatAsync([message], options); - Assert.That(completion.Usage.OutputTokenDetails.AcceptedPredictionTokenCount, Is.GreaterThan(0)); + Assert.That(completion.Usage.OutputTokenDetails.AcceptedPredictionTokenCount, Is.GreaterThan(0)); + } } #endif diff --git a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml index f5580bb17..dd9474ca1 100644 --- a/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml +++ b/.openapi3.azure/openapi3-azure-openai-2025-01-01-preview-generated.yaml @@ -1035,7 +1035,7 @@ components: prediction: type: object allOf: - - $ref: '#/components/schemas/OpenAI.PredictionContent' + - $ref: '#/components/schemas/OpenAI.ChatOutputPrediction' nullable: true description: |- Configuration for a [Predicted Output](/docs/guides/predicted-outputs), @@ -2462,6 +2462,51 @@ components: `none` is the default when no tools are present. `auto` is the default if tools are present. x-oaiExpandable: true + OpenAI.ChatOutputPrediction: + type: object + required: + - type + properties: + type: + anyOf: + - type: string + - type: string + enum: + - content + discriminator: + propertyName: type + mapping: + content: '#/components/schemas/OpenAI.ChatOutputPredictionContent' + description: Base representation of predicted output from a model. + OpenAI.ChatOutputPredictionContent: + type: object + required: + - type + - content + properties: + type: + type: string + enum: + - content + description: |- + The type of the predicted content you want to provide. This type is + currently always `content`. + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' + description: |- + The content that should be matched when generating a model response. + If generated tokens would match this content, the entire model response + can be returned much more quickly. + x-oaiExpandable: true + allOf: + - $ref: '#/components/schemas/OpenAI.ChatOutputPrediction' + description: |- + Static predicted output content, such as the content of a text file that is + being regenerated. OpenAI.ChatResponseFormat: type: object required: @@ -3134,33 +3179,6 @@ components: OpenAI.ParallelToolCalls: type: boolean description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. - OpenAI.PredictionContent: - type: object - required: - - type - - content - properties: - type: - type: string - enum: - - content - description: |- - The type of the predicted content you want to provide. This type is - currently always `content`. - content: - anyOf: - - type: string - - type: array - items: - $ref: '#/components/schemas/OpenAI.ChatCompletionRequestMessageContentPartText' - description: |- - The content that should be matched when generating a model response. - If generated tokens would match this content, the entire model response - can be returned much more quickly. - x-oaiExpandable: true - description: |- - Static predicted output content, such as the content of a text file that is - being regenerated. OpenAI.ResponseFormatJsonSchemaSchema: type: object additionalProperties: {} From 86f397966e5f13ed69db2b4c2e204a77d1d3be26 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Mon, 3 Feb 2025 18:55:00 -0800 Subject: [PATCH 38/44] push assets again (stale file bug) --- .dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json index f602fdfae..a62e6ee5b 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "dotnet.azure/openai/Azure.AI.OpenAI", - "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_1e5ebe7b60" + "Tag": "dotnet.azure/openai/Azure.AI.OpenAI_9ba94506a0" } From 536a3f08e3f0b5e9493ba51d944e18f00033f8c2 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Tue, 4 Feb 2025 14:26:11 -0800 Subject: [PATCH 39/44] PR feedback --- .../Custom/Files/AzureOpenAIFileCollection.cs | 2 +- .../Custom/Assistants/RunStepToolCallKind.cs | 2 +- .../Custom/Files/Internal/GeneratorStubs.cs | 1 + .../src/Custom/Files/OpenAIFileCollection.cs | 9 +- .../Models/InternalListFilesResponseObject.cs | 41 +++++ ...ileSearchObjectFileSearch.Serialization.cs | 170 ++++++++++++++++++ ...ailsToolCallsFileSearchObjectFileSearch.cs | 35 ++++ ...etailsToolCallsCodeObject.Serialization.cs | 17 +- ...ternalRunStepDetailsToolCallsCodeObject.cs | 4 +- ...ToolCallsFileSearchObject.Serialization.cs | 17 +- ...RunStepDetailsToolCallsFileSearchObject.cs | 4 +- ...lsToolCallsFunctionObject.Serialization.cs | 17 +- ...alRunStepDetailsToolCallsFunctionObject.cs | 4 +- .../OpenAIFileCollection.Serialization.cs | 2 +- ...epFileSearchResultContent.Serialization.cs | 10 +- .../Models/RunStepFileSearchResultContent.cs | 3 +- .../src/Generated/Models/RunStepToolCall.cs | 1 - .openapi3/openapi3-openai.yaml | 46 +++-- .typespec/administration/models.tsp | 32 ++++ .typespec/files/models.tsp | 4 +- .typespec/fine-tuning/models.tsp | 2 +- .typespec/organization/models.tsp | 18 -- .typespec/runs/custom.tsp | 4 +- .typespec/runs/models.tsp | 43 ++--- .typespec/uploads/models.tsp | 24 --- README.md | 4 +- 26 files changed, 376 insertions(+), 140 deletions(-) create mode 100644 .dotnet/src/Generated/Models/InternalListFilesResponseObject.cs create mode 100644 .dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs create mode 100644 .dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.cs delete mode 100644 .typespec/organization/models.tsp diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.cs index d5d6e55bf..24eef4e3d 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFileCollection.cs @@ -11,7 +11,7 @@ internal partial class AzureOpenAIFileCollection : OpenAIFileCollection internal new IDictionary SerializedAdditionalRawData { get; } = new ChangeTrackingDictionary(); - internal string Object { get; } + internal string Object { get; } = "list"; internal AzureOpenAIFileCollection() : this( diff --git a/.dotnet/src/Custom/Assistants/RunStepToolCallKind.cs b/.dotnet/src/Custom/Assistants/RunStepToolCallKind.cs index f4d83a56f..f99fc0a7d 100644 --- a/.dotnet/src/Custom/Assistants/RunStepToolCallKind.cs +++ b/.dotnet/src/Custom/Assistants/RunStepToolCallKind.cs @@ -3,7 +3,7 @@ namespace OpenAI.Assistants; [Experimental("OPENAI001")] -[CodeGenModel("RunStepDetailsToolCallKind")] +[CodeGenModel("RunStepDetailsToolCallType")] public enum RunStepToolCallKind { CodeInterpreter, diff --git a/.dotnet/src/Custom/Files/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/Files/Internal/GeneratorStubs.cs index ea48db3c9..509a21a93 100644 --- a/.dotnet/src/Custom/Files/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/Files/Internal/GeneratorStubs.cs @@ -10,6 +10,7 @@ internal readonly partial struct InternalOpenAIFileObject { } [CodeGenModel("CompleteUploadRequest")] internal partial class InternalCompleteUploadRequest { } [CodeGenModel("CreateUploadRequest")] internal partial class InternalCreateUploadRequest { } [CodeGenModel("CreateUploadRequestPurpose")] internal readonly partial struct InternalCreateUploadRequestPurpose { } +[CodeGenModel("ListFilesResponseObject")] internal readonly partial struct InternalListFilesResponseObject { } [CodeGenModel("Upload")] internal partial class InternalUpload { } [CodeGenModel("UploadObject")] internal readonly partial struct InternalUploadObject { } [CodeGenModel("UploadPart")] internal partial class InternalUploadPart { } diff --git a/.dotnet/src/Custom/Files/OpenAIFileCollection.cs b/.dotnet/src/Custom/Files/OpenAIFileCollection.cs index e6db62a02..4693bb44d 100644 --- a/.dotnet/src/Custom/Files/OpenAIFileCollection.cs +++ b/.dotnet/src/Custom/Files/OpenAIFileCollection.cs @@ -7,13 +7,13 @@ namespace OpenAI.Files; [CodeGenModel("ListFilesResponse")] [CodeGenSuppress("Data")] [CodeGenSuppress(nameof(OpenAIFileCollection))] -[CodeGenSuppress(nameof(OpenAIFileCollection), typeof(string), typeof(string), typeof(string), typeof(bool))] -[CodeGenSuppress(nameof(OpenAIFileCollection), typeof(string), typeof(string), typeof(string), typeof(bool), typeof(IDictionary))] +[CodeGenSuppress(nameof(OpenAIFileCollection), typeof(string), typeof(string), typeof(bool))] +[CodeGenSuppress(nameof(OpenAIFileCollection), typeof(InternalListFilesResponseObject), typeof(string), typeof(string), typeof(bool), typeof(IDictionary))] public partial class OpenAIFileCollection : ReadOnlyCollection { // CUSTOM: Made private. This property does not add value in the context of a strongly-typed class. - /// Gets the object. - private string Object { get; } + [CodeGenMember("Object")] + private InternalListFilesResponseObject Object { get; } = InternalListFilesResponseObject.List; // CUSTOM: Internalizing pending stanardized pagination representation for the list operation. [CodeGenMember("FirstId")] @@ -31,7 +31,6 @@ public partial class OpenAIFileCollection : ReadOnlyCollection internal OpenAIFileCollection(IEnumerable data, string firstId, string lastId, bool hasMore) : base([.. data]) { - Object = "list"; Argument.AssertNotNull(data, nameof(data)); FirstId = firstId; LastId = lastId; diff --git a/.dotnet/src/Generated/Models/InternalListFilesResponseObject.cs b/.dotnet/src/Generated/Models/InternalListFilesResponseObject.cs new file mode 100644 index 000000000..2fa2419c8 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalListFilesResponseObject.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Files +{ + internal readonly partial struct InternalListFilesResponseObject : IEquatable + { + private readonly string _value; + private const string ListValue = "list"; + + public InternalListFilesResponseObject(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalListFilesResponseObject List { get; } = new InternalListFilesResponseObject(ListValue); + + public static bool operator ==(InternalListFilesResponseObject left, InternalListFilesResponseObject right) => left.Equals(right); + + public static bool operator !=(InternalListFilesResponseObject left, InternalListFilesResponseObject right) => !left.Equals(right); + + public static implicit operator InternalListFilesResponseObject(string value) => new InternalListFilesResponseObject(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListFilesResponseObject other && Equals(other); + + public bool Equals(InternalListFilesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs new file mode 100644 index 000000000..6b443b8b1 --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs @@ -0,0 +1,170 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace OpenAI.Assistants +{ + internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch)} does not support writing '{format}' format."); + } + if (true && Optional.IsCollectionDefined(Results) && _additionalBinaryDataProperties?.ContainsKey("results") != true) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (RunStepFileSearchResult item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(RankingOptions) && _additionalBinaryDataProperties?.ContainsKey("ranking_options") != true) + { + writer.WritePropertyName("ranking_options"u8); + writer.WriteObjectValue(RankingOptions, options); + } + if (true && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, options); + } + + internal static InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList results = default; + FileSearchRankingOptions rankingOptions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("results"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(RunStepFileSearchResult.DeserializeRunStepFileSearchResult(item, options)); + } + results = array; + continue; + } + if (prop.NameEquals("ranking_options"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(prop.Value, options); + continue; + } + if (true) + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(results ?? new ChangeTrackingList(), rankingOptions, additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch)} does not support writing '{options.Format}' format."); + } + } + + InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + protected virtual InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + public static implicit operator BinaryContent(InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch internalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch) + { + if (internalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch == null) + { + return null; + } + return BinaryContent.Create(internalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch, ModelSerializationExtensions.WireOptions); + } + + public static explicit operator InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.cs b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.cs new file mode 100644 index 000000000..610b1286c --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace OpenAI.Assistants +{ + internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch + { + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch() + { + Results = new ChangeTrackingList(); + } + + internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObjectFileSearch(IReadOnlyList results, FileSearchRankingOptions rankingOptions, IDictionary additionalBinaryDataProperties) + { + Results = results; + RankingOptions = rankingOptions; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public IReadOnlyList Results { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.Serialization.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.Serialization.cs index d6cb108b2..ee963279b 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.Serialization.cs @@ -32,11 +32,6 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObject)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } if (_additionalBinaryDataProperties?.ContainsKey("code_interpreter") != true) { writer.WritePropertyName("code_interpreter"u8); @@ -63,20 +58,20 @@ internal static InternalRunStepDetailsToolCallsCodeObject DeserializeInternalRun { return null; } + string id = default; Assistants.RunStepToolCallKind kind = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string id = default; InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("type"u8)) + if (prop.NameEquals("id"u8)) { - kind = prop.Value.GetString().ToRunStepToolCallKind(); + id = prop.Value.GetString(); continue; } - if (prop.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = prop.Value.GetString(); + kind = prop.Value.GetString().ToRunStepToolCallKind(); continue; } if (prop.NameEquals("code_interpreter"u8)) @@ -89,7 +84,7 @@ internal static InternalRunStepDetailsToolCallsCodeObject DeserializeInternalRun additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRunStepDetailsToolCallsCodeObject(kind, additionalBinaryDataProperties, id, codeInterpreter); + return new InternalRunStepDetailsToolCallsCodeObject(id, kind, additionalBinaryDataProperties, codeInterpreter); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.cs index d6352e9c1..1901d9b3a 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObject.cs @@ -14,13 +14,11 @@ internal InternalRunStepDetailsToolCallsCodeObject(string id, InternalRunStepDet CodeInterpreter = codeInterpreter; } - internal InternalRunStepDetailsToolCallsCodeObject(Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, string id, InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) : base(id, kind, additionalBinaryDataProperties) + internal InternalRunStepDetailsToolCallsCodeObject(string id, Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) : base(id, kind, additionalBinaryDataProperties) { CodeInterpreter = codeInterpreter; } - public new string Id => _id ?? default; - public InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter CodeInterpreter { get; } } } diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.Serialization.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.Serialization.cs index 45ac8525f..c3383210e 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.Serialization.cs @@ -32,11 +32,6 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObject)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } if (_additionalBinaryDataProperties?.ContainsKey("file_search") != true) { writer.WritePropertyName("file_search"u8); @@ -63,20 +58,20 @@ internal static InternalRunStepDetailsToolCallsFileSearchObject DeserializeInter { return null; } + string id = default; Assistants.RunStepToolCallKind kind = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string id = default; InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("type"u8)) + if (prop.NameEquals("id"u8)) { - kind = prop.Value.GetString().ToRunStepToolCallKind(); + id = prop.Value.GetString(); continue; } - if (prop.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = prop.Value.GetString(); + kind = prop.Value.GetString().ToRunStepToolCallKind(); continue; } if (prop.NameEquals("file_search"u8)) @@ -89,7 +84,7 @@ internal static InternalRunStepDetailsToolCallsFileSearchObject DeserializeInter additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRunStepDetailsToolCallsFileSearchObject(kind, additionalBinaryDataProperties, id, fileSearch); + return new InternalRunStepDetailsToolCallsFileSearchObject(id, kind, additionalBinaryDataProperties, fileSearch); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.cs index 5d0f596f2..3346c806c 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObject.cs @@ -14,13 +14,11 @@ internal InternalRunStepDetailsToolCallsFileSearchObject(string id, InternalRunS FileSearch = fileSearch; } - internal InternalRunStepDetailsToolCallsFileSearchObject(Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, string id, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base(id, kind, additionalBinaryDataProperties) + internal InternalRunStepDetailsToolCallsFileSearchObject(string id, Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base(id, kind, additionalBinaryDataProperties) { FileSearch = fileSearch; } - public new string Id => _id ?? default; - public InternalRunStepDetailsToolCallsFileSearchObjectFileSearch FileSearch { get; } } } diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.Serialization.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.Serialization.cs index 7fa61d5e6..b2de59874 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.Serialization.cs @@ -32,11 +32,6 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObject)} does not support writing '{format}' format."); } base.JsonModelWriteCore(writer, options); - if (_additionalBinaryDataProperties?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } if (_additionalBinaryDataProperties?.ContainsKey("function") != true) { writer.WritePropertyName("function"u8); @@ -63,20 +58,20 @@ internal static InternalRunStepDetailsToolCallsFunctionObject DeserializeInterna { return null; } + string id = default; Assistants.RunStepToolCallKind kind = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - string id = default; InternalRunStepDetailsToolCallsFunctionObjectFunction function = default; foreach (var prop in element.EnumerateObject()) { - if (prop.NameEquals("type"u8)) + if (prop.NameEquals("id"u8)) { - kind = prop.Value.GetString().ToRunStepToolCallKind(); + id = prop.Value.GetString(); continue; } - if (prop.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = prop.Value.GetString(); + kind = prop.Value.GetString().ToRunStepToolCallKind(); continue; } if (prop.NameEquals("function"u8)) @@ -89,7 +84,7 @@ internal static InternalRunStepDetailsToolCallsFunctionObject DeserializeInterna additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalRunStepDetailsToolCallsFunctionObject(kind, additionalBinaryDataProperties, id, function); + return new InternalRunStepDetailsToolCallsFunctionObject(id, kind, additionalBinaryDataProperties, function); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.cs b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.cs index abe30aeb9..a6c864fee 100644 --- a/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.cs +++ b/.dotnet/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObject.cs @@ -14,13 +14,11 @@ internal InternalRunStepDetailsToolCallsFunctionObject(string id, InternalRunSte Function = function; } - internal InternalRunStepDetailsToolCallsFunctionObject(Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, string id, InternalRunStepDetailsToolCallsFunctionObjectFunction function) : base(id, kind, additionalBinaryDataProperties) + internal InternalRunStepDetailsToolCallsFunctionObject(string id, Assistants.RunStepToolCallKind kind, IDictionary additionalBinaryDataProperties, InternalRunStepDetailsToolCallsFunctionObjectFunction function) : base(id, kind, additionalBinaryDataProperties) { Function = function; } - public new string Id => _id ?? default; - public InternalRunStepDetailsToolCallsFunctionObjectFunction Function { get; } } } diff --git a/.dotnet/src/Generated/Models/OpenAIFileCollection.Serialization.cs b/.dotnet/src/Generated/Models/OpenAIFileCollection.Serialization.cs index 78729d5de..b7a296137 100644 --- a/.dotnet/src/Generated/Models/OpenAIFileCollection.Serialization.cs +++ b/.dotnet/src/Generated/Models/OpenAIFileCollection.Serialization.cs @@ -22,7 +22,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("object") != true) { writer.WritePropertyName("object"u8); - writer.WriteStringValue(this.Object); + writer.WriteStringValue(this.Object.ToString()); } if (_additionalBinaryDataProperties?.ContainsKey("first_id") != true) { diff --git a/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.Serialization.cs b/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.Serialization.cs index f66c049a2..26de3553b 100644 --- a/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.Serialization.cs +++ b/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.Serialization.cs @@ -13,6 +13,10 @@ namespace OpenAI.Assistants { public partial class RunStepFileSearchResultContent : IJsonModel { + internal RunStepFileSearchResultContent() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -27,7 +31,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { throw new FormatException($"The model {nameof(RunStepFileSearchResultContent)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Text) && _additionalBinaryDataProperties?.ContainsKey("text") != true) + if (_additionalBinaryDataProperties?.ContainsKey("text") != true) { writer.WritePropertyName("text"u8); writer.WriteStringValue(Text); @@ -89,10 +93,6 @@ internal static RunStepFileSearchResultContent DeserializeRunStepFileSearchResul } if (prop.NameEquals("type"u8)) { - if (prop.Value.ValueKind == JsonValueKind.Null) - { - continue; - } kind = prop.Value.GetString().ToRunStepFileSearchResultContentKind(); continue; } diff --git a/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.cs b/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.cs index 95d299b19..8324a3dbd 100644 --- a/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.cs +++ b/.dotnet/src/Generated/Models/RunStepFileSearchResultContent.cs @@ -11,8 +11,9 @@ public partial class RunStepFileSearchResultContent { private protected IDictionary _additionalBinaryDataProperties; - internal RunStepFileSearchResultContent() + internal RunStepFileSearchResultContent(string text) { + Text = text; } internal RunStepFileSearchResultContent(string text, Assistants.RunStepFileSearchResultContentKind kind, IDictionary additionalBinaryDataProperties) diff --git a/.dotnet/src/Generated/Models/RunStepToolCall.cs b/.dotnet/src/Generated/Models/RunStepToolCall.cs index 1fee31ebd..a1ff98139 100644 --- a/.dotnet/src/Generated/Models/RunStepToolCall.cs +++ b/.dotnet/src/Generated/Models/RunStepToolCall.cs @@ -10,7 +10,6 @@ namespace OpenAI.Assistants public abstract partial class RunStepToolCall { private protected IDictionary _additionalBinaryDataProperties; - private protected string _id; private protected RunStepToolCall(string id, Assistants.RunStepToolCallKind kind) { diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index 12550a147..78f510744 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -2972,6 +2972,21 @@ components: format: unixtime role: type: string + ApiKeyList: + type: object + properties: + object: + type: string + data: + type: array + items: + $ref: '#/components/schemas/AdminApiKey' + has_more: + type: boolean + first_id: + type: string + last_id: + type: string AssistantObject: type: object required: @@ -8234,6 +8249,8 @@ components: properties: object: type: string + enum: + - list data: type: array items: @@ -12699,7 +12716,15 @@ components: description: The type of tool call. This is always going to be `file_search` for this type of tool call. file_search: type: object - additionalProperties: {} + properties: + ranking_options: + $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchRankingOptionsObject' + results: + type: array + items: + $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchResultObject' + description: The results of the file search. + readOnly: true description: For now, this is always going to be an empty object. x-oaiTypeLabel: map allOf: @@ -12794,7 +12819,7 @@ components: allOf: - $ref: '#/components/schemas/RunStepObjectStepDetails' description: Details of the message creation by the run step. - RunStepDetailsToolCallKind: + RunStepDetailsToolCallType: anyOf: - type: string - type: string @@ -12805,13 +12830,9 @@ components: RunStepDetailsToolCallsCodeObject: type: object required: - - id - type - code_interpreter properties: - id: - type: string - description: The ID of the tool call. type: type: string enum: @@ -12892,13 +12913,9 @@ components: RunStepDetailsToolCallsFileSearchObject: type: object required: - - id - type - file_search properties: - id: - type: string - description: The ID of the tool call object. type: type: string enum: @@ -12969,6 +12986,9 @@ components: text: type: string description: The text content of the file. + required: + - type + - text description: The content of the result that was found. The content is only included if requested via the include query parameter. readOnly: true description: A result instance of the file search. @@ -12976,13 +12996,9 @@ components: RunStepDetailsToolCallsFunctionObject: type: object required: - - id - type - function properties: - id: - type: string - description: The ID of the tool call object. type: type: string enum: @@ -13036,7 +13052,7 @@ components: properties: type: allOf: - - $ref: '#/components/schemas/RunStepDetailsToolCallKind' + - $ref: '#/components/schemas/RunStepDetailsToolCallType' description: The discriminated type identifier for the details object. id: type: string diff --git a/.typespec/administration/models.tsp b/.typespec/administration/models.tsp index 2e76978a5..572a44208 100644 --- a/.typespec/administration/models.tsp +++ b/.typespec/administration/models.tsp @@ -25,6 +25,38 @@ alias InviteRequestProject = { role: "member" | "owner"; }; +model AdminApiKey { + object?: string; + id?: string; + name?: string; + redacted_value?: string; + value?: string; + + // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime + @encode("unixTimestamp", int64) + created_at?: utcDateTime; + + owner?: { + type?: string; + id?: string; + name?: string; + + // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime + @encode("unixTimestamp", int64) + created_at?: utcDateTime; + + role?: string; + }; +} + +model ApiKeyList { + object?: string; + data?: AdminApiKey[]; + has_more?: boolean; + first_id?: string; + last_id?: string; +} + /** The service account that performed the audit logged action. */ model AuditLogActorServiceAccount { /** The service account id. */ diff --git a/.typespec/files/models.tsp b/.typespec/files/models.tsp index 6656037e6..2832f1c6b 100644 --- a/.typespec/files/models.tsp +++ b/.typespec/files/models.tsp @@ -20,7 +20,9 @@ model CreateFileRequest { } model ListFilesResponse { - object: string; + // Tool customization: apply the strict 'list' object value instead of open 'string' + object: "list"; + data: OpenAIFile[]; first_id: string; last_id: string; diff --git a/.typespec/fine-tuning/models.tsp b/.typespec/fine-tuning/models.tsp index 62f511e16..3d036af62 100644 --- a/.typespec/fine-tuning/models.tsp +++ b/.typespec/fine-tuning/models.tsp @@ -217,7 +217,7 @@ model FineTuningJob { validation_file: string | null; /** A list of integrations to enable for this fine-tuning job. */ - // !no_nullable! @maxItems(5) + // Tool note: can't automatically apply to nullable: @maxItems(5) @extension("x-oaiExpandable", true) integrations?: FineTuningIntegration[] | null; diff --git a/.typespec/organization/models.tsp b/.typespec/organization/models.tsp deleted file mode 100644 index 4bbb8edfa..000000000 --- a/.typespec/organization/models.tsp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file was automatically generated from an OpenAPI .yaml file. - * Edits made directly to this file will be lost. - */ - -import "../uploads"; - -using TypeSpec.OpenAPI; - -namespace OpenAI; - -model ApiKeyList { - object?: string; - data?: AdminApiKey[]; - has_more?: boolean; - first_id?: string; - last_id?: string; -} diff --git a/.typespec/runs/custom.tsp b/.typespec/runs/custom.tsp index 044a1f0c8..7c5a59fb1 100644 --- a/.typespec/runs/custom.tsp +++ b/.typespec/runs/custom.tsp @@ -18,7 +18,7 @@ model RunStepObjectStepDetails { type: string; } -union RunStepDetailsToolCallKind { +union RunStepDetailsToolCallType { string, code_interpreter: "code_interpreter", file_search: "file_search", @@ -31,7 +31,7 @@ union RunStepDetailsToolCallKind { @discriminator("type") model RunStepDetailsToolCallsObjectToolCallsObject { /** The discriminated type identifier for the details object. */ - type: RunStepDetailsToolCallKind; + type: RunStepDetailsToolCallType; /** The ID of the tool call object. */ id: string; diff --git a/.typespec/runs/models.tsp b/.typespec/runs/models.tsp index 86f9d5e24..a9689c980 100644 --- a/.typespec/runs/models.tsp +++ b/.typespec/runs/models.tsp @@ -26,11 +26,13 @@ alias SubmitToolOutputsRunRequestToolOutput = { // Tool generated type. Extracts from RunStepDetailsToolCallsFileSearchResultObject.content alias RunStepDetailsToolCallsFileSearchResultObjectContent = { + // Tool customization: address source spec inaccuracy of optionality /** The type of the content. */ - type?: "text"; + type: "text"; + // Tool customization: address source spec inaccuracy of optionality /** The text content of the file. */ - text?: string; + text: string; }; model CreateRunRequest { @@ -78,7 +80,7 @@ model CreateRunRequest { // Tool customization: use common model base for tool definitions /** Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ - // !no_nullable! @maxItems(20) + // Tool note: can't automatically apply to nullable: @maxItems(20) @extension("x-oaiExpandable", true) tools?: AssistantToolDefinition[] | null; @@ -166,7 +168,7 @@ model CreateThreadAndRunRequest { // Tool customization: use common model base for tool definitions /** Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ - // !no_nullable! @maxItems(20) + // Tool note: can't automatically apply to nullable: @maxItems(20) tools?: AssistantToolDefinition[] | null; @doc(""" @@ -284,17 +286,15 @@ model RunStepDetailsToolCallsObject extends RunStepObjectStepDetails { tool_calls: RunStepDetailsToolCallsObjectToolCallsObject[]; } -// Tool customization: apply custom, common base type to union items +// Tool customization: Remove parent-relocated 'id' from discriminated type instance /** Details of the Code Interpreter tool call the run step was involved in. */ model RunStepDetailsToolCallsCodeObject extends RunStepDetailsToolCallsObjectToolCallsObject { - /** The ID of the tool call. */ - id: string; - + // Tool customization: apply named discriminator enumeration instead of anonymous string @doc(""" The type of tool call. This is always going to be `code_interpreter` for this type of tool call. """) - type: "code_interpreter"; + type: RunStepDetailsToolCallType.code_interpreter; /** The Code Interpreter tool call definition. */ code_interpreter: { @@ -338,16 +338,14 @@ model RunStepDetailsToolCallsCodeOutputImageObject }; } -// Tool customization: apply custom, common base type to union items +// Tool customization: Remove parent-relocated 'id' from discriminated type instance model RunStepDetailsToolCallsFileSearchObject extends RunStepDetailsToolCallsObjectToolCallsObject { - /** The ID of the tool call object. */ - id: string; - + // Tool customization: apply named discriminator enumeration instead of anonymous string @doc(""" The type of tool call. This is always going to be `file_search` for this type of tool call. """) - type: "file_search"; + type: RunStepDetailsToolCallType.file_search; /** For now, this is always going to be an empty object. */ @extension("x-oaiTypeLabel", "map") @@ -390,16 +388,14 @@ model RunStepDetailsToolCallsFileSearchResultObject { content?: RunStepDetailsToolCallsFileSearchResultObjectContent[]; } -// Tool customization: apply custom, common base type to union items +// Tool customization: Remove parent-relocated 'id' from discriminated type instance model RunStepDetailsToolCallsFunctionObject extends RunStepDetailsToolCallsObjectToolCallsObject { - /** The ID of the tool call object. */ - id: string; - + // Tool customization: apply named discriminator enumeration instead of anonymous string @doc(""" The type of tool call. This is always going to be `function` for this type of tool call. """) - type: "function"; + type: RunStepDetailsToolCallType.function; /** The definition of the function that was called. */ function: { @@ -801,9 +797,16 @@ model RunStepDeltaStepDetailsToolCallsFileSearchObject """) type: "file_search"; + // Tool customization: add missing and shared file_search definition for streaming /** For now, this is always going to be an empty object. */ @extension("x-oaiTypeLabel", "map") - file_search: Record; + file_search: { + ranking_options?: RunStepDetailsToolCallsFileSearchRankingOptionsObject; + + /** The results of the file search. */ + @visibility("read") + results?: RunStepDetailsToolCallsFileSearchResultObject[]; + }; } // Tool customization: apply custom, common base type to union items diff --git a/.typespec/uploads/models.tsp b/.typespec/uploads/models.tsp index 539d13eb3..79b1f875b 100644 --- a/.typespec/uploads/models.tsp +++ b/.typespec/uploads/models.tsp @@ -9,30 +9,6 @@ using TypeSpec.OpenAPI; namespace OpenAI; -model AdminApiKey { - object?: string; - id?: string; - name?: string; - redacted_value?: string; - value?: string; - - // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime - @encode("unixTimestamp", int64) - created_at?: utcDateTime; - - owner?: { - type?: string; - id?: string; - name?: string; - - // Tool customization: 'created' and fields ending in '_at' are Unix encoded utcDateTime - @encode("unixTimestamp", int64) - created_at?: utcDateTime; - - role?: string; - }; -} - model CreateUploadRequest { /** The name of the file to upload. */ filename: string; diff --git a/README.md b/README.md index de2d4b823..82d0c9282 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Date: Fri Jan 31 21:29:23 2025 +0000 Ingestion tool: https://project-argos@dev.azure.com/project-argos/Sorento/_git/sdk ``` -commit 4e2e95153f2e504245a014ec1f27229d39f0529f (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) +commit 5493c9222e4ca5d015822629d4f4235544036daa (HEAD -> user/travisw/migrate-spec-ingestion-tool, origin/user/travisw/migrate-spec-ingestion-tool) Author: Travis Wilson -Date: Mon Feb 3 18:29:01 2025 -0800 +Date: Tue Feb 4 14:24:59 2025 -0800 ``` There are some deltas: From 4a8d7f8394d7e67d7cb6bbbca9964c9a99f87171 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Tue, 4 Feb 2025 14:40:06 -0800 Subject: [PATCH 40/44] fix filemocks tests -- 'object': 'list' is required --- .dotnet/tests/Files/FilesMockTests.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.dotnet/tests/Files/FilesMockTests.cs b/.dotnet/tests/Files/FilesMockTests.cs index 25bbbe508..eace0f3ff 100644 --- a/.dotnet/tests/Files/FilesMockTests.cs +++ b/.dotnet/tests/Files/FilesMockTests.cs @@ -265,6 +265,7 @@ public async Task GetFilesDeserializesId() { OpenAIClientOptions clientOptions = GetClientOptionsWithMockResponse(200, """ { + "object": "list", "data": [ { "id": "returned_file_id" @@ -287,6 +288,7 @@ public async Task GetFilesDeserializesCreatedAt() { OpenAIClientOptions clientOptions = GetClientOptionsWithMockResponse(200, """ { + "object": "list", "data": [ { "created_at": 1704096000 @@ -310,6 +312,7 @@ public async Task GetFilesDeserializesPurpose((string stringValue, FilePurpose e { OpenAIClientOptions clientOptions = GetClientOptionsWithMockResponse(200, $$""" { + "object": "list", "data": [ { "purpose": "{{purpose.stringValue}}" @@ -334,6 +337,7 @@ public async Task GetFilesDeserializesStatus((string stringValue, FileStatus exp { OpenAIClientOptions clientOptions = GetClientOptionsWithMockResponse(200, $$""" { + "object": "list", "data": [ { "status": "{{status.stringValue}}" @@ -358,6 +362,7 @@ public async Task GetFilesDeserializesStatusDetails() { OpenAIClientOptions clientOptions = GetClientOptionsWithMockResponse(200, """ { + "object": "list", "data": [ { "status_details": "This is definitely an error." From a1ff6610776a6e100d03250c3cda2781b0656aae Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 5 Feb 2025 14:15:58 -0800 Subject: [PATCH 41/44] PR feedback --- .dotnet/api/OpenAI.netstandard2.0.cs | 16 +------- .../AssistantChatMessage.Serialization.cs | 19 +-------- .../Chat/ChatMessageContent.Serialization.cs | 2 + .../src/Custom/Chat/ChatOutputPrediction.cs | 4 -- .../src/Custom/Chat/DeveloperChatMessage.cs | 6 +-- .../Chat/FunctionChatMessage.Serialization.cs | 9 +---- .../ChatOutputPredictionKind.cs | 4 +- .../Custom/Chat/InternalPredictionContent.cs | 13 ------- .../src/Custom/Chat/OpenAIChatModelFactory.cs | 6 +-- .../Chat/SystemChatMessage.Serialization.cs | 14 +------ .dotnet/src/Custom/Chat/SystemChatMessage.cs | 2 +- .../Chat/UserChatMessage.Serialization.cs | 14 +------ .../ChatOutputPrediction.Serialization.cs | 2 +- .../Generated/Models/ChatOutputPrediction.cs | 10 +++-- .../Models/ChatOutputPredictionKind.cs | 39 ------------------- ...atOutputPredictionContent.Serialization.cs | 6 +-- .../InternalChatOutputPredictionContent.cs | 4 +- .../InternalChatOutputPredictionKind.cs | 39 +++++++++++++++++++ ...knownChatOutputPrediction.Serialization.cs | 6 +-- .../InternalUnknownChatOutputPrediction.cs | 2 +- .dotnet/src/Generated/OpenAIModelFactory.cs | 4 +- .dotnet/tests/Chat/ChatTests.cs | 1 - 22 files changed, 74 insertions(+), 148 deletions(-) rename .dotnet/src/Custom/Chat/{ => Internal}/ChatOutputPredictionKind.cs (53%) delete mode 100644 .dotnet/src/Custom/Chat/InternalPredictionContent.cs delete mode 100644 .dotnet/src/Generated/Models/ChatOutputPredictionKind.cs create mode 100644 .dotnet/src/Generated/Models/InternalChatOutputPredictionKind.cs diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 500959bb6..71f7d7310 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1411,25 +1411,11 @@ public class ChatOutputAudioReference : IJsonModel, IP public override readonly string ToString(); } public class ChatOutputPrediction : IJsonModel, IPersistableModel { - public ChatOutputPredictionKind Kind { get; } public static ChatOutputPrediction CreateStaticContentPrediction(IEnumerable contentParts); public static ChatOutputPrediction CreateStaticContentPrediction(string content); public static explicit operator ChatOutputPrediction(ClientResult result); public static implicit operator BinaryContent(ChatOutputPrediction chatOutputPrediction); } - public readonly partial struct ChatOutputPredictionKind : IEquatable { - public ChatOutputPredictionKind(string value); - public static ChatOutputPredictionKind StaticContent { get; } - public readonly bool Equals(ChatOutputPredictionKind other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(ChatOutputPredictionKind left, ChatOutputPredictionKind right); - public static implicit operator ChatOutputPredictionKind(string value); - public static bool operator !=(ChatOutputPredictionKind left, ChatOutputPredictionKind right); - public override readonly string ToString(); - } public class ChatOutputTokenUsageDetails : IJsonModel, IPersistableModel { public int AcceptedPredictionTokenCount { get; } public int AudioTokenCount { get; } @@ -1550,7 +1536,7 @@ public static class OpenAIChatModelFactory { public static ChatCompletion ChatCompletion(string id = null, ChatFinishReason finishReason = ChatFinishReason.Stop, ChatMessageContent content = null, string refusal = null, IEnumerable toolCalls = null, ChatMessageRole role = ChatMessageRole.System, ChatFunctionCall functionCall = null, IEnumerable contentTokenLogProbabilities = null, IEnumerable refusalTokenLogProbabilities = null, DateTimeOffset createdAt = default, string model = null, string systemFingerprint = null, ChatTokenUsage usage = null, ChatOutputAudio outputAudio = null); public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTokenCount = 0, int cachedTokenCount = 0); public static ChatOutputAudio ChatOutputAudio(BinaryData audioBytes, string id = null, string transcript = null, DateTimeOffset expiresAt = default); - public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = 0, int audioTokenCount = 0, int predictionAcceptedTokenCount = 0, int predictionRejectedTokenCount = 0); + public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = 0, int audioTokenCount = 0, int acceptedPredictionTokenCount = 0, int rejectedPredictionTokenCount = 0); public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null); public static ChatTokenTopLogProbabilityDetails ChatTokenTopLogProbabilityDetails(string token = null, float logProbability = 0, ReadOnlyMemory? utf8Bytes = null); public static ChatTokenUsage ChatTokenUsage(int outputTokenCount = 0, int inputTokenCount = 0, int totalTokenCount = 0, ChatOutputTokenUsageDetails outputTokenDetails = null, ChatInputTokenUsageDetails inputTokenDetails = null); diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs index f12246a67..abce9ea91 100644 --- a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs @@ -21,23 +21,8 @@ internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions // Content is optional, can be a single string or a collection of ChatMessageContentPart. if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) { - if (Content.Count > 0) - { - writer.WritePropertyName("content"u8); - if (Content.Count == 1 && Content[0].Text != null) - { - writer.WriteStringValue(Content[0].Text); - } - else - { - writer.WriteStartArray(); - foreach (ChatMessageContentPart part in Content) - { - writer.WriteObjectValue(part, options); - } - writer.WriteEndArray(); - } - } + writer.WritePropertyName("content"u8); + Content.WriteTo(writer, options); } writer.WriteOptionalProperty("refusal"u8, Refusal, options); diff --git a/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs b/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs index edc1fc3ae..692ef3d4a 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs @@ -11,6 +11,7 @@ public partial class ChatMessageContent { internal void WriteTo(Utf8JsonWriter writer, ModelReaderWriterOptions options = null) { + options ??= new("W"); if (Count == 0) { writer.WriteNullValue(); @@ -32,6 +33,7 @@ internal void WriteTo(Utf8JsonWriter writer, ModelReaderWriterOptions options = internal static ChatMessageContent DeserializeChatMessageContent(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new("W"); if (element.ValueKind == JsonValueKind.String) { return new(element.GetString()); diff --git a/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs b/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs index e1825c4e9..172d0a1ff 100644 --- a/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs +++ b/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs @@ -7,10 +7,6 @@ namespace OpenAI.Chat; [CodeGenModel("ChatOutputPrediction")] public partial class ChatOutputPrediction { - // CUSTOM: Rename; add public visibility for derived type discriminator insight. - [CodeGenMember("Type")] - public ChatOutputPredictionKind Kind { get; } - public static ChatOutputPrediction CreateStaticContentPrediction(IEnumerable contentParts) => new InternalChatOutputPredictionContent(new ChatMessageContent(contentParts)); diff --git a/.dotnet/src/Custom/Chat/DeveloperChatMessage.cs b/.dotnet/src/Custom/Chat/DeveloperChatMessage.cs index c24323a13..e21ae9c01 100644 --- a/.dotnet/src/Custom/Chat/DeveloperChatMessage.cs +++ b/.dotnet/src/Custom/Chat/DeveloperChatMessage.cs @@ -14,18 +14,18 @@ public partial class DeveloperChatMessage : ChatMessage { /// /// Creates a new instance of using a collection of content items. - /// For system messages, these can only be of type text. + /// For developer messages, these can only be of type text. /// /// /// The collection of content items associated with the message. /// public DeveloperChatMessage(IEnumerable contentParts) - : base(ChatMessageRole.System, contentParts) + : base(ChatMessageRole.Developer, contentParts) { } /// /// Creates a new instance of using a collection of content items. - /// For system messages, these can only be of type text. + /// For developer messages, these can only be of type text. /// /// /// The collection of content items associated with the message. diff --git a/.dotnet/src/Custom/Chat/FunctionChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/FunctionChatMessage.Serialization.cs index d3618bb1a..cf8fca13f 100644 --- a/.dotnet/src/Custom/Chat/FunctionChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/FunctionChatMessage.Serialization.cs @@ -26,14 +26,7 @@ internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) { writer.WritePropertyName("content"u8); - if (Content.Count > 0 && Content[0].Text != null) - { - writer.WriteStringValue(Content[0].Text); - } - else - { - writer.WriteNullValue(); - } + Content.WriteTo(writer, options); } writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); diff --git a/.dotnet/src/Custom/Chat/ChatOutputPredictionKind.cs b/.dotnet/src/Custom/Chat/Internal/ChatOutputPredictionKind.cs similarity index 53% rename from .dotnet/src/Custom/Chat/ChatOutputPredictionKind.cs rename to .dotnet/src/Custom/Chat/Internal/ChatOutputPredictionKind.cs index 2cc902f30..c0ee32bb1 100644 --- a/.dotnet/src/Custom/Chat/ChatOutputPredictionKind.cs +++ b/.dotnet/src/Custom/Chat/Internal/ChatOutputPredictionKind.cs @@ -5,9 +5,9 @@ namespace OpenAI.Chat; [CodeGenModel("ChatOutputPredictionType")] -public readonly partial struct ChatOutputPredictionKind +internal readonly partial struct InternalChatOutputPredictionKind { // CUSTOM: Rename for clarity. [CodeGenMember("Content")] - public static ChatOutputPredictionKind StaticContent { get; } = new ChatOutputPredictionKind(ContentValue); + public static InternalChatOutputPredictionKind StaticContent { get; } = new InternalChatOutputPredictionKind(ContentValue); } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/InternalPredictionContent.cs b/.dotnet/src/Custom/Chat/InternalPredictionContent.cs deleted file mode 100644 index 26427685f..000000000 --- a/.dotnet/src/Custom/Chat/InternalPredictionContent.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Chat; - -// CUSTOM: Added base type. - -[CodeGenModel("PredictionContent")] -internal partial class InternalPredictionContent : ChatOutputPrediction -{ - -} \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs index 81240a87a..4a08548ab 100644 --- a/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs +++ b/.dotnet/src/Custom/Chat/OpenAIChatModelFactory.cs @@ -116,13 +116,13 @@ public static ChatInputTokenUsageDetails ChatInputTokenUsageDetails(int audioTok /// Initializes a new instance of . /// A new instance for mocking. - public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default, int audioTokenCount = default, int predictionAcceptedTokenCount = default, int predictionRejectedTokenCount = 0) + public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default, int audioTokenCount = default, int acceptedPredictionTokenCount = default, int rejectedPredictionTokenCount = 0) { return new ChatOutputTokenUsageDetails( audioTokenCount: audioTokenCount, reasoningTokenCount: reasoningTokenCount, - acceptedPredictionTokenCount: predictionAcceptedTokenCount, - rejectedPredictionTokenCount: predictionRejectedTokenCount, + acceptedPredictionTokenCount: acceptedPredictionTokenCount, + rejectedPredictionTokenCount: rejectedPredictionTokenCount, additionalBinaryDataProperties: null); } diff --git a/.dotnet/src/Custom/Chat/SystemChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/SystemChatMessage.Serialization.cs index 4907c78bc..cd8da0ccd 100644 --- a/.dotnet/src/Custom/Chat/SystemChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/SystemChatMessage.Serialization.cs @@ -23,19 +23,7 @@ internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) { writer.WritePropertyName("content"u8); - if (Content.Count == 1 && Content[0].Text != null) - { - writer.WriteStringValue(Content[0].Text); - } - else - { - writer.WriteStartArray(); - foreach (ChatMessageContentPart part in Content) - { - writer.WriteObjectValue(part, options); - } - writer.WriteEndArray(); - } + Content.WriteTo(writer, options); } writer.WriteOptionalProperty("name"u8, ParticipantName, options); diff --git a/.dotnet/src/Custom/Chat/SystemChatMessage.cs b/.dotnet/src/Custom/Chat/SystemChatMessage.cs index 8e4cad09d..946295bd1 100644 --- a/.dotnet/src/Custom/Chat/SystemChatMessage.cs +++ b/.dotnet/src/Custom/Chat/SystemChatMessage.cs @@ -6,7 +6,7 @@ namespace OpenAI.Chat; /// Represents a chat message of the system role as supplied to a chat completion request. A system message is /// generally supplied as the first message to a chat completion request and guides the model's behavior across future /// assistant role response messages. These messages may help control behavior, style, tone, and -/// restrictions for a model-based assistant. +/// restrictions for a model-based assistant. Developer messages replace system messages for o1 models and newer. /// [CodeGenModel("ChatCompletionRequestSystemMessage")] [CodeGenSuppress("SystemChatMessage", typeof(ChatMessageContent))] diff --git a/.dotnet/src/Custom/Chat/UserChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/UserChatMessage.Serialization.cs index 615d62feb..8a2d1a827 100644 --- a/.dotnet/src/Custom/Chat/UserChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/UserChatMessage.Serialization.cs @@ -22,19 +22,7 @@ internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) { writer.WritePropertyName("content"u8); - if (Content.Count == 1 && Content[0].Text != null) - { - writer.WriteStringValue(Content[0].Text); - } - else - { - writer.WriteStartArray(); - foreach (ChatMessageContentPart part in Content) - { - writer.WriteObjectValue(part, options); - } - writer.WriteEndArray(); - } + Content.WriteTo(writer, options); } writer.WriteOptionalProperty("name"u8, ParticipantName, options); diff --git a/.dotnet/src/Generated/Models/ChatOutputPrediction.Serialization.cs b/.dotnet/src/Generated/Models/ChatOutputPrediction.Serialization.cs index 09cc097e1..ec8e32b7b 100644 --- a/.dotnet/src/Generated/Models/ChatOutputPrediction.Serialization.cs +++ b/.dotnet/src/Generated/Models/ChatOutputPrediction.Serialization.cs @@ -34,7 +34,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (_additionalBinaryDataProperties?.ContainsKey("type") != true) { writer.WritePropertyName("type"u8); - writer.WriteStringValue(Kind.ToString()); + writer.WriteStringValue(Type.ToString()); } if (true && _additionalBinaryDataProperties != null) { diff --git a/.dotnet/src/Generated/Models/ChatOutputPrediction.cs b/.dotnet/src/Generated/Models/ChatOutputPrediction.cs index b16c0970e..380f12d3f 100644 --- a/.dotnet/src/Generated/Models/ChatOutputPrediction.cs +++ b/.dotnet/src/Generated/Models/ChatOutputPrediction.cs @@ -11,17 +11,19 @@ public partial class ChatOutputPrediction { private protected IDictionary _additionalBinaryDataProperties; - private protected ChatOutputPrediction(ChatOutputPredictionKind kind) + private protected ChatOutputPrediction(InternalChatOutputPredictionKind @type) { - Kind = kind; + Type = @type; } - internal ChatOutputPrediction(ChatOutputPredictionKind kind, IDictionary additionalBinaryDataProperties) + internal ChatOutputPrediction(InternalChatOutputPredictionKind @type, IDictionary additionalBinaryDataProperties) { - Kind = kind; + Type = @type; _additionalBinaryDataProperties = additionalBinaryDataProperties; } + internal InternalChatOutputPredictionKind Type { get; set; } + internal IDictionary SerializedAdditionalRawData { get => _additionalBinaryDataProperties; diff --git a/.dotnet/src/Generated/Models/ChatOutputPredictionKind.cs b/.dotnet/src/Generated/Models/ChatOutputPredictionKind.cs deleted file mode 100644 index fcff96daa..000000000 --- a/.dotnet/src/Generated/Models/ChatOutputPredictionKind.cs +++ /dev/null @@ -1,39 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Chat -{ - public readonly partial struct ChatOutputPredictionKind : IEquatable - { - private readonly string _value; - private const string ContentValue = "content"; - - public ChatOutputPredictionKind(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static bool operator ==(ChatOutputPredictionKind left, ChatOutputPredictionKind right) => left.Equals(right); - - public static bool operator !=(ChatOutputPredictionKind left, ChatOutputPredictionKind right) => !left.Equals(right); - - public static implicit operator ChatOutputPredictionKind(string value) => new ChatOutputPredictionKind(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ChatOutputPredictionKind other && Equals(other); - - public bool Equals(ChatOutputPredictionKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.Serialization.cs b/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.Serialization.cs index fdf1443cc..b87396419 100644 --- a/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.Serialization.cs @@ -59,14 +59,14 @@ internal static InternalChatOutputPredictionContent DeserializeInternalChatOutpu { return null; } - ChatOutputPredictionKind kind = default; + InternalChatOutputPredictionKind @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); ChatMessageContent content = default; foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) { - kind = new ChatOutputPredictionKind(prop.Value.GetString()); + @type = new InternalChatOutputPredictionKind(prop.Value.GetString()); continue; } if (prop.NameEquals("content"u8)) @@ -79,7 +79,7 @@ internal static InternalChatOutputPredictionContent DeserializeInternalChatOutpu additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalChatOutputPredictionContent(kind, additionalBinaryDataProperties, content); + return new InternalChatOutputPredictionContent(@type, additionalBinaryDataProperties, content); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.cs b/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.cs index e927b3799..e23a7c124 100644 --- a/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.cs +++ b/.dotnet/src/Generated/Models/InternalChatOutputPredictionContent.cs @@ -10,14 +10,14 @@ namespace OpenAI.Chat { internal partial class InternalChatOutputPredictionContent : ChatOutputPrediction { - public InternalChatOutputPredictionContent(ChatMessageContent content) : base(ChatOutputPredictionKind.StaticContent) + public InternalChatOutputPredictionContent(ChatMessageContent content) : base(InternalChatOutputPredictionKind.StaticContent) { Argument.AssertNotNull(content, nameof(content)); Content = content; } - internal InternalChatOutputPredictionContent(ChatOutputPredictionKind kind, IDictionary additionalBinaryDataProperties, ChatMessageContent content) : base(kind, additionalBinaryDataProperties) + internal InternalChatOutputPredictionContent(InternalChatOutputPredictionKind @type, IDictionary additionalBinaryDataProperties, ChatMessageContent content) : base(@type, additionalBinaryDataProperties) { Content = content; } diff --git a/.dotnet/src/Generated/Models/InternalChatOutputPredictionKind.cs b/.dotnet/src/Generated/Models/InternalChatOutputPredictionKind.cs new file mode 100644 index 000000000..051d77c6c --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalChatOutputPredictionKind.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Chat +{ + internal readonly partial struct InternalChatOutputPredictionKind : IEquatable + { + private readonly string _value; + private const string ContentValue = "content"; + + public InternalChatOutputPredictionKind(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static bool operator ==(InternalChatOutputPredictionKind left, InternalChatOutputPredictionKind right) => left.Equals(right); + + public static bool operator !=(InternalChatOutputPredictionKind left, InternalChatOutputPredictionKind right) => !left.Equals(right); + + public static implicit operator InternalChatOutputPredictionKind(string value) => new InternalChatOutputPredictionKind(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalChatOutputPredictionKind other && Equals(other); + + public bool Equals(InternalChatOutputPredictionKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.Serialization.cs b/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.Serialization.cs index 2bdf952c1..ba0c062c7 100644 --- a/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.Serialization.cs +++ b/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.Serialization.cs @@ -52,13 +52,13 @@ internal static InternalUnknownChatOutputPrediction DeserializeInternalUnknownCh { return null; } - ChatOutputPredictionKind kind = default; + InternalChatOutputPredictionKind @type = default; IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); foreach (var prop in element.EnumerateObject()) { if (prop.NameEquals("type"u8)) { - kind = new ChatOutputPredictionKind(prop.Value.GetString()); + @type = new InternalChatOutputPredictionKind(prop.Value.GetString()); continue; } if (true) @@ -66,7 +66,7 @@ internal static InternalUnknownChatOutputPrediction DeserializeInternalUnknownCh additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - return new InternalUnknownChatOutputPrediction(kind, additionalBinaryDataProperties); + return new InternalUnknownChatOutputPrediction(@type, additionalBinaryDataProperties); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); diff --git a/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.cs b/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.cs index a65d8f269..6de1ab5c2 100644 --- a/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.cs +++ b/.dotnet/src/Generated/Models/InternalUnknownChatOutputPrediction.cs @@ -9,7 +9,7 @@ namespace OpenAI.Chat { internal partial class InternalUnknownChatOutputPrediction : ChatOutputPrediction { - internal InternalUnknownChatOutputPrediction(ChatOutputPredictionKind kind, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", additionalBinaryDataProperties) + internal InternalUnknownChatOutputPrediction(InternalChatOutputPredictionKind @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) { } } diff --git a/.dotnet/src/Generated/OpenAIModelFactory.cs b/.dotnet/src/Generated/OpenAIModelFactory.cs index c859314a4..809cb209d 100644 --- a/.dotnet/src/Generated/OpenAIModelFactory.cs +++ b/.dotnet/src/Generated/OpenAIModelFactory.cs @@ -1032,10 +1032,10 @@ public static FunctionChatMessage FunctionChatMessage(ChatMessageContent content return new FunctionChatMessage(content, Chat.ChatMessageRole.Function, additionalBinaryDataProperties: null, functionName); } - public static ChatOutputPrediction ChatOutputPrediction(string kind = default) + public static ChatOutputPrediction ChatOutputPrediction(string @type = default) { - return new InternalUnknownChatOutputPrediction(new ChatOutputPredictionKind(kind), additionalBinaryDataProperties: null); + return new InternalUnknownChatOutputPrediction(new InternalChatOutputPredictionKind(@type), additionalBinaryDataProperties: null); } public static ChatAudioOptions ChatAudioOptions(ChatOutputAudioVoice outputAudioVoice = default, ChatOutputAudioFormat outputAudioFormat = default) diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index 47bc369a2..2df172abf 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -928,7 +928,6 @@ public async Task PredictedOutputsWork() { OutputPrediction = predictionVariant, }; - Assert.That(options.OutputPrediction.Kind, Is.EqualTo(ChatOutputPredictionKind.StaticContent)); ChatMessage message = ChatMessage.CreateUserMessage(""" Modify the following input to enable the feature. Only respond with the JSON and include no other text. Do not enclose in markdown backticks or any other additional annotations. From 2964005c7a51b0145b1598deb6d8d52e487e86d4 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 5 Feb 2025 14:28:59 -0800 Subject: [PATCH 42/44] test merge --- .dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs index ba94cb65f..737f80951 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs @@ -783,7 +783,6 @@ public async Task PredictedOutputsWork() { OutputPrediction = predictionVariant, }; - Assert.That(options.OutputPrediction.Kind, Is.EqualTo(ChatOutputPredictionKind.StaticContent)); ChatMessage message = ChatMessage.CreateUserMessage(""" Modify the following input to enable the feature. Only respond with the JSON and include no other text. Do not enclose in markdown backticks or any other additional annotations. From 306f0a91d4e153f0d1bb1ced98dc87f220abad20 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Wed, 5 Feb 2025 15:01:46 -0800 Subject: [PATCH 43/44] address constructor --- .../Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs | 3 +++ .../Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs index 196fe7fea..00cba9a5c 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/UserSecurityContext.cs @@ -21,4 +21,7 @@ public partial class UserSecurityContext /// Captures the original client's IP address. [CodeGenMember("SourceIp")] public string SourceIP { get; set; } + + public UserSecurityContext() + { } } \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs index 5d38a1d50..fdce17d7b 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs @@ -41,10 +41,6 @@ public partial class UserSecurityContext /// /// internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal UserSecurityContext() - { - } /// Initializes a new instance of . /// The name of the application. Sensitive personal information should not be included in this field. From 50ec586294cdb4ef3d42c77923d12bbed9fdbdc9 Mon Sep 17 00:00:00 2001 From: Travis Wilson Date: Thu, 6 Feb 2025 12:44:20 -0800 Subject: [PATCH 44/44] PR feedback, image test reliability for owls --- .dotnet/api/OpenAI.netstandard2.0.cs | 4 +- .../Chat/ChatMessageContent.Serialization.cs | 1 - .../src/Custom/Chat/ChatOutputPrediction.cs | 8 +-- ...cs => InternalChatOutputPredictionKind.cs} | 0 .../AssistantChatMessage.Serialization.cs | 12 +---- .../{ => Messages}/AssistantChatMessage.cs | 0 .../ChatMessage.Serialization.cs | 17 +++++++ .../Custom/Chat/{ => Messages}/ChatMessage.cs | 0 .../DeveloperChatMessage.Serialization.cs | 24 +-------- .../{ => Messages}/DeveloperChatMessage.cs | 0 .../FunctionChatMessage.Serialization.cs | 12 +---- .../{ => Messages}/FunctionChatMessage.cs | 0 .../SystemChatMessage.Serialization.cs | 12 +---- .../Chat/{ => Messages}/SystemChatMessage.cs | 0 .../ToolChatMessage.Serialization.cs | 24 +-------- .../Chat/{ => Messages}/ToolChatMessage.cs | 0 .../UserChatMessage.Serialization.cs | 12 +---- .../Chat/{ => Messages}/UserChatMessage.cs | 0 .dotnet/tests/Chat/ChatTests.cs | 8 +-- .dotnet/tests/Images/ImagesTests.cs | 49 +++++++++++-------- 20 files changed, 67 insertions(+), 116 deletions(-) rename .dotnet/src/Custom/Chat/Internal/{ChatOutputPredictionKind.cs => InternalChatOutputPredictionKind.cs} (100%) rename .dotnet/src/Custom/Chat/{ => Messages}/AssistantChatMessage.Serialization.cs (77%) rename .dotnet/src/Custom/Chat/{ => Messages}/AssistantChatMessage.cs (100%) rename .dotnet/src/Custom/Chat/{ => Messages}/ChatMessage.Serialization.cs (72%) rename .dotnet/src/Custom/Chat/{ => Messages}/ChatMessage.cs (100%) rename .dotnet/src/Custom/Chat/{ => Messages}/DeveloperChatMessage.Serialization.cs (58%) rename .dotnet/src/Custom/Chat/{ => Messages}/DeveloperChatMessage.cs (100%) rename .dotnet/src/Custom/Chat/{ => Messages}/FunctionChatMessage.Serialization.cs (75%) rename .dotnet/src/Custom/Chat/{ => Messages}/FunctionChatMessage.cs (100%) rename .dotnet/src/Custom/Chat/{ => Messages}/SystemChatMessage.Serialization.cs (73%) rename .dotnet/src/Custom/Chat/{ => Messages}/SystemChatMessage.cs (100%) rename .dotnet/src/Custom/Chat/{ => Messages}/ToolChatMessage.Serialization.cs (57%) rename .dotnet/src/Custom/Chat/{ => Messages}/ToolChatMessage.cs (100%) rename .dotnet/src/Custom/Chat/{ => Messages}/UserChatMessage.Serialization.cs (72%) rename .dotnet/src/Custom/Chat/{ => Messages}/UserChatMessage.cs (100%) diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index 71f7d7310..84d1f0fa1 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -1411,8 +1411,8 @@ public class ChatOutputAudioReference : IJsonModel, IP public override readonly string ToString(); } public class ChatOutputPrediction : IJsonModel, IPersistableModel { - public static ChatOutputPrediction CreateStaticContentPrediction(IEnumerable contentParts); - public static ChatOutputPrediction CreateStaticContentPrediction(string content); + public static ChatOutputPrediction CreateStaticContentPrediction(IEnumerable staticContentParts); + public static ChatOutputPrediction CreateStaticContentPrediction(string staticContent); public static explicit operator ChatOutputPrediction(ClientResult result); public static implicit operator BinaryContent(ChatOutputPrediction chatOutputPrediction); } diff --git a/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs b/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs index 692ef3d4a..6bae53715 100644 --- a/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs +++ b/.dotnet/src/Custom/Chat/ChatMessageContent.Serialization.cs @@ -11,7 +11,6 @@ public partial class ChatMessageContent { internal void WriteTo(Utf8JsonWriter writer, ModelReaderWriterOptions options = null) { - options ??= new("W"); if (Count == 0) { writer.WriteNullValue(); diff --git a/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs b/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs index 172d0a1ff..d355c4d38 100644 --- a/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs +++ b/.dotnet/src/Custom/Chat/ChatOutputPrediction.cs @@ -7,9 +7,9 @@ namespace OpenAI.Chat; [CodeGenModel("ChatOutputPrediction")] public partial class ChatOutputPrediction { - public static ChatOutputPrediction CreateStaticContentPrediction(IEnumerable contentParts) - => new InternalChatOutputPredictionContent(new ChatMessageContent(contentParts)); + public static ChatOutputPrediction CreateStaticContentPrediction(IEnumerable staticContentParts) + => new InternalChatOutputPredictionContent(new ChatMessageContent(staticContentParts)); - public static ChatOutputPrediction CreateStaticContentPrediction(string content) - => new InternalChatOutputPredictionContent([ChatMessageContentPart.CreateTextPart(content)]); + public static ChatOutputPrediction CreateStaticContentPrediction(string staticContent) + => new InternalChatOutputPredictionContent([ChatMessageContentPart.CreateTextPart(staticContent)]); } \ No newline at end of file diff --git a/.dotnet/src/Custom/Chat/Internal/ChatOutputPredictionKind.cs b/.dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionKind.cs similarity index 100% rename from .dotnet/src/Custom/Chat/Internal/ChatOutputPredictionKind.cs rename to .dotnet/src/Custom/Chat/Internal/InternalChatOutputPredictionKind.cs diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/Messages/AssistantChatMessage.Serialization.cs similarity index 77% rename from .dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs rename to .dotnet/src/Custom/Chat/Messages/AssistantChatMessage.Serialization.cs index abce9ea91..a38e14039 100644 --- a/.dotnet/src/Custom/Chat/AssistantChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/Messages/AssistantChatMessage.Serialization.cs @@ -15,16 +15,8 @@ internal static void SerializeAssistantChatMessage(AssistantChatMessage instance internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); - - // Content is optional, can be a single string or a collection of ChatMessageContentPart. - if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) - { - writer.WritePropertyName("content"u8); - Content.WriteTo(writer, options); - } - + WriteRoleProperty(writer, options); + WriteContentProperty(writer, options); writer.WriteOptionalProperty("refusal"u8, Refusal, options); writer.WriteOptionalProperty("name"u8, ParticipantName, options); writer.WriteOptionalCollection("tool_calls"u8, ToolCalls, options); diff --git a/.dotnet/src/Custom/Chat/AssistantChatMessage.cs b/.dotnet/src/Custom/Chat/Messages/AssistantChatMessage.cs similarity index 100% rename from .dotnet/src/Custom/Chat/AssistantChatMessage.cs rename to .dotnet/src/Custom/Chat/Messages/AssistantChatMessage.cs diff --git a/.dotnet/src/Custom/Chat/ChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/Messages/ChatMessage.Serialization.cs similarity index 72% rename from .dotnet/src/Custom/Chat/ChatMessage.Serialization.cs rename to .dotnet/src/Custom/Chat/Messages/ChatMessage.Serialization.cs index b36120df9..384a67d1b 100644 --- a/.dotnet/src/Custom/Chat/ChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/Messages/ChatMessage.Serialization.cs @@ -30,4 +30,21 @@ internal static void WriteCore(ChatMessage instance, Utf8JsonWriter writer, Mode internal virtual void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw new InvalidOperationException($"The {nameof(WriteCore)} method should be invoked on an overriding type derived from {nameof(ChatMessage)}."); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal void WriteRoleProperty(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToSerialString()); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal void WriteContentProperty(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) + { + writer.WritePropertyName("content"u8); + Content.WriteTo(writer, options); + } + } } diff --git a/.dotnet/src/Custom/Chat/ChatMessage.cs b/.dotnet/src/Custom/Chat/Messages/ChatMessage.cs similarity index 100% rename from .dotnet/src/Custom/Chat/ChatMessage.cs rename to .dotnet/src/Custom/Chat/Messages/ChatMessage.cs diff --git a/.dotnet/src/Custom/Chat/DeveloperChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/Messages/DeveloperChatMessage.Serialization.cs similarity index 58% rename from .dotnet/src/Custom/Chat/DeveloperChatMessage.Serialization.cs rename to .dotnet/src/Custom/Chat/Messages/DeveloperChatMessage.Serialization.cs index 26dadf39e..56b11107a 100644 --- a/.dotnet/src/Custom/Chat/DeveloperChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/Messages/DeveloperChatMessage.Serialization.cs @@ -16,28 +16,8 @@ internal static void SerializeDeveloperChatMessage(DeveloperChatMessage instance internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); - - // Content is required, can be a single string or a collection of ChatMessageContentPart. - if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) - { - writer.WritePropertyName("content"u8); - if (Content.Count == 1 && Content[0].Text != null) - { - writer.WriteStringValue(Content[0].Text); - } - else - { - writer.WriteStartArray(); - foreach (ChatMessageContentPart part in Content) - { - writer.WriteObjectValue(part, options); - } - writer.WriteEndArray(); - } - } - + WriteRoleProperty(writer, options); + WriteContentProperty(writer, options); writer.WriteOptionalProperty("name"u8, ParticipantName, options); writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); writer.WriteEndObject(); diff --git a/.dotnet/src/Custom/Chat/DeveloperChatMessage.cs b/.dotnet/src/Custom/Chat/Messages/DeveloperChatMessage.cs similarity index 100% rename from .dotnet/src/Custom/Chat/DeveloperChatMessage.cs rename to .dotnet/src/Custom/Chat/Messages/DeveloperChatMessage.cs diff --git a/.dotnet/src/Custom/Chat/FunctionChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/Messages/FunctionChatMessage.Serialization.cs similarity index 75% rename from .dotnet/src/Custom/Chat/FunctionChatMessage.Serialization.cs rename to .dotnet/src/Custom/Chat/Messages/FunctionChatMessage.Serialization.cs index cf8fca13f..68fea522b 100644 --- a/.dotnet/src/Custom/Chat/FunctionChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/Messages/FunctionChatMessage.Serialization.cs @@ -17,18 +17,10 @@ internal static void SerializeFunctionChatMessage(FunctionChatMessage instance, internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); + WriteRoleProperty(writer, options); + WriteContentProperty(writer, options); writer.WritePropertyName("name"u8); writer.WriteStringValue(FunctionName); - - // Content is required, can be a single string or null. - if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) - { - writer.WritePropertyName("content"u8); - Content.WriteTo(writer, options); - } - writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); writer.WriteEndObject(); } diff --git a/.dotnet/src/Custom/Chat/FunctionChatMessage.cs b/.dotnet/src/Custom/Chat/Messages/FunctionChatMessage.cs similarity index 100% rename from .dotnet/src/Custom/Chat/FunctionChatMessage.cs rename to .dotnet/src/Custom/Chat/Messages/FunctionChatMessage.cs diff --git a/.dotnet/src/Custom/Chat/SystemChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/Messages/SystemChatMessage.Serialization.cs similarity index 73% rename from .dotnet/src/Custom/Chat/SystemChatMessage.Serialization.cs rename to .dotnet/src/Custom/Chat/Messages/SystemChatMessage.Serialization.cs index cd8da0ccd..debd1f9b9 100644 --- a/.dotnet/src/Custom/Chat/SystemChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/Messages/SystemChatMessage.Serialization.cs @@ -16,16 +16,8 @@ internal static void SerializeSystemChatMessage(SystemChatMessage instance, Utf8 internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); - - // Content is required, can be a single string or a collection of ChatMessageContentPart. - if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) - { - writer.WritePropertyName("content"u8); - Content.WriteTo(writer, options); - } - + WriteRoleProperty(writer, options); + WriteContentProperty(writer, options); writer.WriteOptionalProperty("name"u8, ParticipantName, options); writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); writer.WriteEndObject(); diff --git a/.dotnet/src/Custom/Chat/SystemChatMessage.cs b/.dotnet/src/Custom/Chat/Messages/SystemChatMessage.cs similarity index 100% rename from .dotnet/src/Custom/Chat/SystemChatMessage.cs rename to .dotnet/src/Custom/Chat/Messages/SystemChatMessage.cs diff --git a/.dotnet/src/Custom/Chat/ToolChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/Messages/ToolChatMessage.Serialization.cs similarity index 57% rename from .dotnet/src/Custom/Chat/ToolChatMessage.Serialization.cs rename to .dotnet/src/Custom/Chat/Messages/ToolChatMessage.Serialization.cs index b3cc7e417..fb5e88a9e 100644 --- a/.dotnet/src/Custom/Chat/ToolChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/Messages/ToolChatMessage.Serialization.cs @@ -15,30 +15,10 @@ internal static void SerializeToolChatMessage(ToolChatMessage instance, Utf8Json internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); + WriteRoleProperty(writer, options); writer.WritePropertyName("tool_call_id"u8); writer.WriteStringValue(ToolCallId); - - // Content is required, can be a single string or a collection of ChatMessageContentPart. - if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) - { - writer.WritePropertyName("content"u8); - if (Content.Count == 1 && Content[0].Text != null) - { - writer.WriteStringValue(Content[0].Text); - } - else - { - writer.WriteStartArray(); - foreach (ChatMessageContentPart part in Content) - { - writer.WriteObjectValue(part, options); - } - writer.WriteEndArray(); - } - } - + WriteContentProperty(writer, options); writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); writer.WriteEndObject(); } diff --git a/.dotnet/src/Custom/Chat/ToolChatMessage.cs b/.dotnet/src/Custom/Chat/Messages/ToolChatMessage.cs similarity index 100% rename from .dotnet/src/Custom/Chat/ToolChatMessage.cs rename to .dotnet/src/Custom/Chat/Messages/ToolChatMessage.cs diff --git a/.dotnet/src/Custom/Chat/UserChatMessage.Serialization.cs b/.dotnet/src/Custom/Chat/Messages/UserChatMessage.Serialization.cs similarity index 72% rename from .dotnet/src/Custom/Chat/UserChatMessage.Serialization.cs rename to .dotnet/src/Custom/Chat/Messages/UserChatMessage.Serialization.cs index 8a2d1a827..5b09cabf1 100644 --- a/.dotnet/src/Custom/Chat/UserChatMessage.Serialization.cs +++ b/.dotnet/src/Custom/Chat/Messages/UserChatMessage.Serialization.cs @@ -15,16 +15,8 @@ internal static void SerializeUserChatMessage(UserChatMessage instance, Utf8Json internal override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); - - // Content is required, can be a single string or a collection of ChatMessageContentPart. - if (Optional.IsDefined(Content) && Content.IsInnerCollectionDefined()) - { - writer.WritePropertyName("content"u8); - Content.WriteTo(writer, options); - } - + WriteRoleProperty(writer, options); + WriteContentProperty(writer, options); writer.WriteOptionalProperty("name"u8, ParticipantName, options); writer.WriteSerializedAdditionalRawData(_additionalBinaryDataProperties, options); writer.WriteEndObject(); diff --git a/.dotnet/src/Custom/Chat/UserChatMessage.cs b/.dotnet/src/Custom/Chat/Messages/UserChatMessage.cs similarity index 100% rename from .dotnet/src/Custom/Chat/UserChatMessage.cs rename to .dotnet/src/Custom/Chat/Messages/UserChatMessage.cs diff --git a/.dotnet/tests/Chat/ChatTests.cs b/.dotnet/tests/Chat/ChatTests.cs index 2df172abf..04c5db513 100644 --- a/.dotnet/tests/Chat/ChatTests.cs +++ b/.dotnet/tests/Chat/ChatTests.cs @@ -949,8 +949,8 @@ public async Task O3miniDeveloperMessagesWork() { List messages = [ - ChatMessage.CreateDeveloperMessage("When asked questions about naval topics, you always talk like a pirate."), - ChatMessage.CreateUserMessage("What's the best route to sail from San Francisco to New York?") + ChatMessage.CreateDeveloperMessage("End every response to the user with the exact phrase: 'Hope this helps!'"), + ChatMessage.CreateUserMessage("How long will it take to make a cheesecake from scratch? Including getting ingredients.") ]; ChatCompletionOptions options = new() @@ -961,8 +961,8 @@ public async Task O3miniDeveloperMessagesWork() ChatClient client = GetTestClient(TestScenario.Chat, "o3-mini"); ChatCompletion completion = await client.CompleteChatAsync(messages, options); - List expectedPossibles = ["arr", "matey", "hearty", "avast"]; - Assert.That(expectedPossibles.Any(expected => completion.Content[0].Text.ToLower().Contains(expected))); + Assert.That(completion.Content, Has.Count.EqualTo(1)); + Assert.That(completion.Content[0].Text, Does.EndWith("Hope this helps!")); } [Test] diff --git a/.dotnet/tests/Images/ImagesTests.cs b/.dotnet/tests/Images/ImagesTests.cs index 3fe13179a..2246da363 100644 --- a/.dotnet/tests/Images/ImagesTests.cs +++ b/.dotnet/tests/Images/ImagesTests.cs @@ -6,6 +6,7 @@ using System.ClientModel; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; using static OpenAI.Tests.TestHelpers; @@ -47,7 +48,7 @@ public async Task BasicGenerationWorks() Assert.That(image.ImageBytes, Is.Null); Console.WriteLine(image.ImageUri.AbsoluteUri); - ValidateGeneratedImage(image.ImageUri, "stop"); + ValidateGeneratedImage(image.ImageUri, ["stop"]); } [Test] @@ -69,7 +70,7 @@ public async Task GenerationWithOptionsWorks() Assert.That(image.ImageUri, Is.Not.Null); Assert.That(image.ImageBytes, Is.Null); - ValidateGeneratedImage(image.ImageUri, "stop"); + ValidateGeneratedImage(image.ImageUri, ["stop"]); } [Test] @@ -90,7 +91,7 @@ public async Task GenerationWithBytesResponseWorks() Assert.That(image.ImageUri, Is.Null); Assert.That(image.ImageBytes, Is.Not.Null); - ValidateGeneratedImage(image.ImageBytes, "stop"); + ValidateGeneratedImage(image.ImageBytes, ["stop"]); } [Test] @@ -132,7 +133,7 @@ public async Task GenerationOfMultipleImagesWorks() { Assert.That(image.ImageUri, Is.Not.Null); Assert.That(image.ImageBytes, Is.Null); - ValidateGeneratedImage(image.ImageUri, "stop"); + ValidateGeneratedImage(image.ImageUri, ["stop"]); } } @@ -161,7 +162,7 @@ public async Task GenerationOfMultipleImagesWithBytesResponseWorks() { Assert.That(image.ImageUri, Is.Null); Assert.That(image.ImageBytes, Is.Not.Null); - ValidateGeneratedImage(image.ImageBytes, "stop"); + ValidateGeneratedImage(image.ImageBytes, ["stop"]); } } @@ -222,7 +223,7 @@ public async Task GenerateImageEditWorks(ImageSourceKind imageSourceKind) Console.WriteLine(image.ImageUri.AbsoluteUri); - ValidateGeneratedImage(image.ImageUri, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageUri, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } [Test] @@ -262,7 +263,7 @@ public async Task GenerateImageEditWithBytesResponseWorks(ImageSourceKind imageS Assert.That(image.ImageUri, Is.Null); Assert.That(image.ImageBytes, Is.Not.Null); - ValidateGeneratedImage(image.ImageBytes, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageBytes, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } [Test] @@ -345,7 +346,7 @@ public async Task GenerateImageEditWithMaskFileWorks(ImageSourceKind imageSource Console.WriteLine(image.ImageUri.AbsoluteUri); - ValidateGeneratedImage(image.ImageUri, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageUri, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } [Test] @@ -388,7 +389,7 @@ public async Task GenerateImageEditWithMaskFileWithBytesResponseWorks(ImageSourc Assert.That(image.ImageUri, Is.Null); Assert.That(image.ImageBytes, Is.Not.Null); - ValidateGeneratedImage(image.ImageBytes, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageBytes, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } [Test] @@ -478,7 +479,7 @@ public async Task GenerateMultipleImageEditsWorks(ImageSourceKind imageSourceKin Assert.That(image.ImageUri, Is.Not.Null); Assert.That(image.ImageBytes, Is.Null); Console.WriteLine(image.ImageUri.AbsoluteUri); - ValidateGeneratedImage(image.ImageUri, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageUri, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } } @@ -525,7 +526,7 @@ public async Task GenerateMultipleImageEditsWithBytesResponseWorks(ImageSourceKi { Assert.That(image.ImageUri, Is.Null); Assert.That(image.ImageBytes, Is.Not.Null); - ValidateGeneratedImage(image.ImageBytes, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageBytes, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } } @@ -614,7 +615,7 @@ public async Task GenerateMultipleImageEditsWithMaskFileWorks(ImageSourceKind im Assert.That(image.ImageUri, Is.Not.Null); Assert.That(image.ImageBytes, Is.Null); Console.WriteLine(image.ImageUri.AbsoluteUri); - ValidateGeneratedImage(image.ImageUri, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageUri, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } } @@ -664,7 +665,7 @@ public async Task GenerateMultipleImageEditsWithMaskFileWithBytesResponseWorks(I { Assert.That(image.ImageUri, Is.Null); Assert.That(image.ImageBytes, Is.Not.Null); - ValidateGeneratedImage(image.ImageBytes, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageBytes, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } } @@ -753,7 +754,7 @@ public async Task GenerateImageVariationWorks(ImageSourceKind imageSourceKind) Console.WriteLine(image.ImageUri.AbsoluteUri); - ValidateGeneratedImage(image.ImageUri, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageUri, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } [Test] @@ -792,7 +793,7 @@ public async Task GenerateImageVariationWithBytesResponseWorks(ImageSourceKind i Assert.That(image.ImageUri, Is.Null); Assert.That(image.ImageBytes, Is.Not.Null); - ValidateGeneratedImage(image.ImageBytes, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageBytes, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } [Test] @@ -876,7 +877,7 @@ public async Task GenerateMultipleImageVariationsWorks(ImageSourceKind imageSour Assert.That(image.ImageUri, Is.Not.Null); Assert.That(image.ImageBytes, Is.Null); Console.WriteLine(image.ImageUri.AbsoluteUri); - ValidateGeneratedImage(image.ImageUri, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageUri, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } } @@ -922,7 +923,7 @@ public async Task GenerateMultipleImageVariationsWithBytesResponseWorks(ImageSou { Assert.That(image.ImageUri, Is.Null); Assert.That(image.ImageBytes, Is.Not.Null); - ValidateGeneratedImage(image.ImageBytes, "cat", "Note that it likely depicts some sort of animal."); + ValidateGeneratedImage(image.ImageBytes, ["cat", "owl", "animal"], "Note that it likely depicts some sort of animal."); } } @@ -971,7 +972,7 @@ public void GenerateMultipleImageVariationsFromPathCanParseServiceError() #endregion - private void ValidateGeneratedImage(Uri imageUri, string expectedSubstring, string descriptionHint = null) + private void ValidateGeneratedImage(Uri imageUri, IEnumerable possibleExpectedSubstrings, string descriptionHint = null) { ChatClient chatClient = GetTestClient(TestScenario.Chat); IEnumerable messages = [ @@ -982,10 +983,13 @@ private void ValidateGeneratedImage(Uri imageUri, string expectedSubstring, stri ChatCompletionOptions chatOptions = new() { MaxOutputTokenCount = 2048 }; ClientResult result = chatClient.CompleteChat(messages, chatOptions); - Assert.That(result.Value.Content[0].Text.ToLowerInvariant(), Contains.Substring(expectedSubstring)); + Assert.That(result.Value?.Content, Has.Count.EqualTo(1)); + string contentText = result.Value.Content[0].Text.ToLowerInvariant(); + + Assert.That(possibleExpectedSubstrings.Any(possibleExpectedSubstring => contentText.Contains(possibleExpectedSubstring))); } - private void ValidateGeneratedImage(BinaryData imageBytes, string expectedSubstring, string descriptionHint = null) + private void ValidateGeneratedImage(BinaryData imageBytes, IEnumerable possibleExpectedSubstrings, string descriptionHint = null) { ChatClient chatClient = GetTestClient(TestScenario.Chat); IEnumerable messages = [ @@ -996,6 +1000,9 @@ private void ValidateGeneratedImage(BinaryData imageBytes, string expectedSubstr ChatCompletionOptions chatOptions = new() { MaxOutputTokenCount = 2048 }; ClientResult result = chatClient.CompleteChat(messages, chatOptions); - Assert.That(result.Value.Content[0].Text.ToLowerInvariant(), Contains.Substring(expectedSubstring)); + Assert.That(result.Value?.Content, Has.Count.EqualTo(1)); + string contentText = result.Value.Content[0].Text.ToLowerInvariant(); + + Assert.That(possibleExpectedSubstrings.Any(possibleExpectedSubstring => contentText.Contains(possibleExpectedSubstring))); } }